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 |
What is the use of css() method in jquery?
What are selectors in jquery? : jQuery Mobile
What is the difference between event.PreventDefault and event.stopPropagation?
How do you check if an element is empty?
How to Use the jQuery load() Method?
What is the difference between parent() and parents() methods in jQuery?
What were the biggest challenges of getting the jQuery 1.7 release ?
How can you apply a style on an element using jQuery?
How can jquery library be added to pages? Write a basic jquery code?
Difference between javascript and jquery? : jQuery Mobile
What are jquery selectors?
Consider a scenario where things can be done easily with javascript, would you still prefer jQuery?