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

What are the different types of selectors in jquery?

0 Answers  


Hide and show image on button click using jQuery?

0 Answers  


Explain url paremeter of jquery ajax method?

0 Answers  


What happen if you return false from a jQuery event handler?

0 Answers  


Define data paremeter of jquery ajax method?

0 Answers  


Is it possible to hold or delay document.ready execution for sometime?

1 Answers  


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

0 Answers  


What is the need for jquery? : jQuery Mobile

0 Answers  


Tell me how to select combobox select value and text using jquery?

0 Answers  


How do you stop the currently-running animation?

1 Answers  


How to set attributes of an element using jquery?

0 Answers  


What is the use of clone method in jQuery?

0 Answers  


Categories