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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-14 18:23:15 +0000
Seen: 16 times
Last updated: May 14 '23
How can I detect the fullscreen button click event of an HTML5 video?
Why does the alert appear only when I click on something else?
How can I obtain comprehensive logs for Amazon Cognito after an unsuccessful authentication attempt?
Does BlobClient.OpenWriteAsync produce several BlobCreated occurrences?
Why isn't my CodePipeline pipeline triggered by my CloudWatch Event rule?
What is the method for adding markers to a map with the Leaflet "click" event handler?
Is it impossible to prevent event propagation in vuedraggable?
How can an event table be created utilizing FSCalendar?
What is the process for including a delete button in a row that can be clicked?