jQuery Button.click()事件被触发两次 [英] jQuery Button.click() event is triggered twice

查看:110
本文介绍了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.

这篇关于jQuery Button.click()事件被触发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆