Looping through selected values in multiple select combobox JQuery
- by Roland
I have the following scenario.
I have a combobox where multiple selection is available.
<select id="a" multiple="multiple">
<option value="">aaaa</option>
<option value="">bbbb</option>
<option value="">cccc</option>
<option value="">dddd</option>
</select>
Now I also have a button
<button type="button" id="display">Display</button>
When a user clicks on this button, it should list all the selected values of the dropdown in an alert box
My JS code looks as follows
$(document).ready(function() {
$('#display').click(function(){
alert($('#a').val());
});
});
Any pointers will be appreciated