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.
我在做什么错了?
What am I doing wrong?
答
您目前的代码有效,您可以在此尝试: http:// jsfiddle。 net / s4UyH /
Your current code works, you can try it here: http://jsfiddle.net/s4UyH/
您在示例之外触发了另一个 .click()
,检查 的其他处理程序是否触发点击
该元素上的事件。
You have something outside the example triggering another .click()
, check for other handlers that are also triggering a click
event on that element.