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
What is event preventdefault () and event stoppropagation () in jquery?
What programming language does jquery use?
Explain deferred and promise object in jquery? : jquery mobile
Explain the difference between body onload() and document.ready() function? : jquery mobile
What is a jquery ajax?
Why should I use jquery?
What happen if you return false from a jQuery event handler?
Which version of jquery file should be used?
How we can select multiple elements in jquery?
What is the difference between the id selector and class selector in jquery?
What is the difference between "#" and "." selector in JQuery?
Give a brief idea about jquery mobile? : jQuery Mobile
Explain .empty() vs .remove() vs .detach() in jquery
What are the difference between alert() and confirm()?
How to resolve conflicts with other libraries?