Search code examples
jqueryfunctionbuttonclick

jQuery Button.click() event is triggered twice


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?


Solution

  • Your current code works, you can try it here: http://jsfiddle.net/s4UyH/

    You have something outside the example triggering another .click(), check for other handlers that are also triggering a click event on that element.