I have an html dropdown. I want to fire an event whenever the selection changes in any way. I tried r开发者_StackOverflowegistering a 'click' event but this didnt 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?
Try using the onchange
event.
$('#mySelect').change(function(){
alert($(this).val());
});
Would .change() do the trick?
http://api.jquery.com/change/
Certainly there seems to be a working demo of a multi-select box on that page...
jquery 1.4: $("#mySelector").change(myChangeEvent);
before: $("#mySelector").bind("change", myChangeEvent);
function myChangeEvent(e){
}
精彩评论