最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery multiselect event handler - Stack Overflow

programmeradmin3浏览0评论

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?

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?

Share Improve this question edited Apr 16, 2024 at 0:55 informatik01 16.4k11 gold badges78 silver badges108 bronze badges asked Mar 30, 2011 at 20:34 johnjohn 2,8536 gold badges24 silver badges14 bronze badges 1
  • 1 Example: jsfiddle.net/D92z7 – jAndy Commented Mar 30, 2011 at 20:38
Add a comment  | 

3 Answers 3

Reset to default 12

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){

}
发布评论

评论列表(0)

  1. 暂无评论