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


Please Help Members By Posting Answers For Below Questions

Explain deferred and promise object in jquery? : jquery mobile

455


Explain the use of the $.fn.bind and $.fn.trigger.

497


Can you use multiple document.ready() function on the same page?

498


How method can be called inside code behind using jQuery?

452


What are the basic selectors in jQuery?

499






What is CDN?

494


What are the advantage of using cdn? : jquery mobile

466


Why is only the first page of multi page document loaded? : jquery mobile

451


Tell me how to check data type of any variable in jquery? : jquery mobile

425


Why do we need to go for JQuery?

473


How to submit a form without submit button using jquery?

472


Explain why there are two different version of jquery library? : jquery mobile

441


Create a plugin that would add and remove a class on hover.

434


Explain .delegate()? : jquery mobile

476


How to executed jquery selectors? : jquery mobile

456