Saturday, November 1, 2008

[jQuery] Re: Get all values/text and modify each one

On Nov 1, 9:43 am, jetm <javier....@gmail.com> wrote:
> With a multiple select:
>
>  <select id="select1" name="select1" multiple="multiple">
>    <option>Flowers</option>
>    <option>Shrubs</option>
>    <option>Trees</option>
>  </select>
>
> I want output like this: Flowers2; Shrubs2; Trees2;
>
> I using:
>      var str = "";
>      $("#select2").each(function(){
>          str += $(this).text() + ";";
>          $("div").text(str);
>      });
>
> for get all values/text from option and each one modify(add ";")
>
> But the problems is in the output show me this: Flowers2 Shrubs2
> Trees2;
>
> Why this result?
>
> TIA,
> JETM

The answer you find in [1], thanks jay

[1] http://groups.google.com/group/jquery-en/msg/13a6c06a2cc45294

No comments: