Binding multiple events in jQuery

后端 未结 2 1938
清酒与你
清酒与你 2021-02-20 01:24

I have a custom jQuery plugin which binds a change event to a form element, in this case some input elements. The change event is used to

2条回答
  •  离开以前
    2021-02-20 01:47

    You can bind multiple handlers for the same event. Bind the second change as you normally would:

    ​​​​​​​​​​​​​​​
    
    ​$("#a"​).change(function() { alert("1"); });
    $("#a").change(function() { alert("2"); });​
    
    $("#a").change(); // alerts 1, then 2
    

提交回复
热议问题