在JQuery中只触发一个事件
如何使JQuery仅触发您设置的最后一个事件处理程序?例如,在此示例中,我只想启动最后一个警报(“world”)。您可以使用jquery在JQuery中只触发一个事件,jquery,Jquery,如何使JQuery仅触发您设置的最后一个事件处理程序?例如,在此示例中,我只想启动最后一个警报(“world”)。您可以使用jquery 在此处拨弄:您可以解除先前事件处理程序的绑定,并仅附加所需的事件处理程序 element.unbind(event).bind(event,eventHandler); 这里有一种方法 $("#test").click(function() { alert('hello'); return false; }); // Before the last even
在此处拨弄:您可以解除先前事件处理程序的绑定,并仅附加所需的事件处理程序
element.unbind(event).bind(event,eventHandler);
这里有一种方法
$("#test").click(function() { alert('hello'); return false; });
// Before the last event handler.
$("#test").unbind("click");
$("#test").click(function() { alert('world'); return false; });
你的回答与问题无关,可能会把来这里的人弄糊涂。
$("#test").click(function() { alert('hello'); return false; });
// Before the last event handler.
$("#test").unbind("click");
$("#test").click(function() { alert('world'); return false; });