Reputation: 2853
I have an HTML dropdown. I want to fire an event whenever the selection changes in any way.
I tried registering a click
event but this didn't work when multi-selecting (either by dragging the mouse or holding down shift + down arrow).
So basically, how can I fire an event on any selection change?
Upvotes: 7
Views: 37375
Reputation: 2580
Would .change() do the trick?
Certainly there seems to be a working demo of a multi-select box on that page...
Upvotes: 3
Reputation: 227270
Try using the onchange
event.
$('#mySelect').change(function(){
alert($(this).val());
});
Upvotes: 12
Reputation: 4085
jquery 1.4: $("#mySelector").change(myChangeEvent);
before: $("#mySelector").bind("change", myChangeEvent);
function myChangeEvent(e){
}
Upvotes: 0