I have a multiple select tag, and I need to write the function onclick of it\'s options, because I need to get the value of last clicked option, but when I wrote the followi
If you really want to have a click event
on each option, you need to have List
instead of a dropdown
style.
To accomplish that, add the size
attribute into the select
element for instance:
<select type="multiple" size=4>
<option>foo</option>
<option>bar</option>
<option>baseball</option>
</select>
Now you can bind each option
individually.
If you want to get the value of a clicked option use the change
event handler and .val()
method, like:
$("#multiple_select").change(function() {
var val = $(this).val();
alert(val);
});