Select box
<select id="update-select" multiple="multiple">
<option value="3">Test1 </option>
<option value="4">Test2 </option>
<option value="5">Test3 /option>
<option value="6">Test4</option>
<option value="15">Test5</option>
</select>
I am selecting the options from another jquery click function based on some manipulation .
(say i have selected values 3 and 4)
later i want to see the values of selected option
i tried,
selectedVals = $("#update-select option:selected").val() ;
alert(selectedVals) // alerts 3
it shows only the first value selected.
Any suggestion?
这应该做
selectedVals = $("#update-select").val() ;
You should use:
$("#update-select option:selected").each(function(i,elem){
alert($(elem).val());
});
Here's an example: http://jsfiddle.net/5jNWY/
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.