jQuery Button.click() 事件被触发两次 [英] jQuery Button.click() event is triggered twice
本文介绍了jQuery Button.click() 事件被触发两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对这段代码有以下问题:
I have the following problem with this code:
<button id="delete">Remove items</button>
$("#delete").button({
icons: {
primary: 'ui-icon-trash'
}
}).click(function() {
alert("Clicked");
});
如果我单击此按钮,警报会显示两次.它不仅与这个特定按钮有关,而且与我创建的每个按钮有关.
If I click this button, the alert show up two times. It's not only with this specific button but with every single button I create.
我做错了什么?
推荐答案
您当前的代码有效,您可以在这里尝试:http://jsfiddle.net/s4UyH/
Your current code works, you can try it here: http://jsfiddle.net/s4UyH/
您在示例之外触发了另一个 .click()
,检查其他也在该元素上触发click
事件的处理程序.
You have something outside the example triggering another .click()
, check for other handlers that are also triggering a click
event on that element.
这篇关于jQuery Button.click() 事件被触发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文