john
john

Reputation: 2853

jQuery multiselect event handler

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

Answers (3)

thesunneversets
thesunneversets

Reputation: 2580

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...

Upvotes: 3

gen_Eric
gen_Eric

Reputation: 227270

Try using the onchange event.

$('#mySelect').change(function(){
    alert($(this).val());
});

Upvotes: 12

John Hoven
John Hoven

Reputation: 4085

jquery 1.4: $("#mySelector").change(myChangeEvent); before: $("#mySelector").bind("change", myChangeEvent);

function myChangeEvent(e){

}

Upvotes: 0

Related Questions