Reputation: 6246
I use ajax to dynamically populate a drop-down select.
Now i want to send all select option text with my request.
<select name=".." >
<option value="0"> ... </option>
<option value="1"> xxx </option>
<option value="2"> yyy </option>
....
</select>
i want send in request xxx
, yyyy
, ....
Upvotes: 0
Views: 234
Reputation: 11114
you can get all text via JQuery
$.map
is probably the most efficient way to do this.
var options = $('select option');
var values = $.map(options ,function(option) {
return option.innerText;
});
console.log(values);
Upvotes: 1