Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To make a jQuery button work multiple times instead of just once, you need to bind the click event on the button using the on() method rather than the click() method. The click() method binds the click event only once to the element, and it is not re-triggered if the button is clicked again. You can use the on() method with the delegate syntax to bind the click event multiple times to the button. Here's an example:

$("#myButton").on("click", function() {
   // Your code here.
});

Alternatively, you can also use the off() method to remove the previous click event binding before binding the new one:

$("#myButton").off("click").on("click", function() {
   // Your code here.
});

This ensures that the click event is only bound once to the element and avoids multiple event bindings.