I have a multi select dropdown eg:
<select id="myList" multiple="multiple">
<option value="1">Opt #1</option>
<option value="2" selected="selected">Opt #2</option>
<option value="3" selected="selected">Opt #3</option>
<option value="4">Opt #4</option>
</select>
Opt #4
Opt #4
Opt #2
Opt #3
var selectedOptions = $("#myList option:selected");
Opt #4
change
click
You can get it in the click handler for each option element:
$("#myList option").click(function() {
var clickedOption = $(this);
});
Update
EDIT: As I manipulate the list inside a change event, I can't do it in a click event.
In that case you need to delegate the event using on
. Try this:
$("#myList").on("click", "option", function() {
var clickedOption = $(this);
});