I setup a link element and called its click event in jQuery but the click event is calling twice, please see below the code of jQuery.
$("#link_button")
.button()
.click(function () {
$("#attachmentForm").slideToggle("fast");
});
This happens because somewhere in your code, you're rebinding the event handler without first unbinding it.
. click events only work when element gets rendered and are only attached to elements loaded when the DOM is ready. . on events are dynamically attached to DOM elements, which is helpful when you want to attach an event to DOM elements that are rendered on ajax request or something else (after the DOM is ready).
The HTMLElement. click() method simulates a mouse click on an element.
Make sure and check that you have not accidentally included your script twice in your HTML page.
Make un unbind before the click;
$("#link_button").unbind('click');
$("#link_button")
.button()
.click(function () {
$("#attachmentForm").slideToggle("fast");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With