2

i have this html code, how can i get the text which has selected="selected" option with jquery ?

   <option selected="selected" value="1">m</option>
<option value="2">n</option>
<option value="3">o</option>
<option selected="selected" value="4">p</option>
<option value="5">q</option>
<option value="6">r</option>
<option value="7">s</option>
<option selected="selected" value="8">t</option>
<option value="9">u</option>
<option value="10">v</option>

thanks

mosyflasher
  • 489
  • 1
  • 6
  • 16

1 Answers1

1

Well, you can put them in an array

var arr = $('option:selected').map(function(){ return $(this).text() }).get();
// arr[0] = 1
// arr[1] = 4
// arr[2] = 8

I suppose it's multi select.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95