How do you attach a event to element which should be executed only once?
Answer / chaitanya
Using jQuery one() method. This attaches a handler to an event for the element. The handler is executed at most once per element. In simple terms, the attached function will be called only once.
Hide Copy Code
$(document).ready(function() {
$("#btnDummy").one("click", function() {
alert("This will be displayed only once.");
});
});
| Is This Answer Correct ? | 0 Yes | 0 No |
Does events are also copied when you clone any element in jQuery?
What is the difference between onload() and document.ready()?
How to get/set the html contents of an element using jQuery?
Can you write a jquery code to select all links inside the paragraph?
What is jquery.holdready() function?
What is the difference between "#" and "." selector in JQuery?
List the advantages of jquery?
Can we have multiple document.ready() function on the same page?
Where jQuery code is getting executed?
What is get()? : jquery mobile
What is a jquery ajax?
How to use migrate jquery plugin if possible? : jquery mobile