How do you attach a event to element which should be executed only once?
Answer Posted / 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 |
Post New Answer View All Answers
Mention some advantages of jquery.
How we can select multiple elements in jquery?
What is the use of .size() method in jquery?
Define .siblings() method in jquery?
How to check data type of any variable in jquery? : jquery mobile
Create a plugin that would add and remove a class on hover.
How is body onload() function is different from document.ready() function used in jquery?
Explain the difference between parent() and parents() methods in jquery? : jquery mobile
What is the use of each function in jQuery?
How do you get the attribute of an html tag in jquery?
explain bind() vs live() vs delegate() methods in jquery
Explain .empty() vs .remove() vs .detach() in jquery
Define the script build up by jquery?
What is difference between onload and ready?
What is jquery mobile theming? : jquery mobile