How do you attach a event to element which should be executed only once?



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

Post New Answer

More jQuery Interview Questions

How to keep the submit text from showing with jquery mobile? : jquery mobile

0 Answers  


How to select all elements using jQuery?

0 Answers  


What is the slowest selector in jQuery?

0 Answers  


Can we have multiple document.ready() function on the same page? : jquery mobile

0 Answers  


JQuery or JavaScript which is quicker in execution?

0 Answers  






What are source maps in jQuery?

1 Answers  


List the basic selectors in jquery?

0 Answers  


How do you implement animation functionality?

1 Answers  


Explain the difference between jquery-x.x.x.js and jquery.x.x.x min.js?

0 Answers  


What is jquery.holdready() function?

0 Answers  


How can we show and hide an element via jquery?

0 Answers  


What is jQuery plugin and what is the advantage of using plugin?

1 Answers  


Categories