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

Explain .delegate()? : jquery mobile

0 Answers  


How to disable cut,copy and paste in TextBox using jQuery?

0 Answers  


How we can select multiple elements in jquery?

0 Answers  


what does $("div") will select? : jquery mobile

0 Answers  


How is the deferred method in jquery important in relation to animate method?

0 Answers  






How to create clone of any object using jQuery?

1 Answers  


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

0 Answers  


Why we need jquery?

0 Answers  


How can an element be checked if it contains a specific class?

0 Answers  


What is the difference between text() and html() in jquery?

0 Answers  


Define the use of each function in jquery?

0 Answers  


Why is the block display style used for animations?

0 Answers  


Categories