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

How do I check if an element is hidden in jQuery?

621


How do you add an HTML element in DOM tree?

663


Tell me which command will give a version of jquery?

584


What is jquery connect and how to use it?

686


what are the features of jquery

606


Do we need to add jQuery file in both Master and Content page?

604


How to use jquery?

676


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

564


Can there be more than one ready function in jquery?

563


When can you use jquery?

632


What is the use of jQuery load method?

656


Explain data paremeter of jquery ajax method?

6731


Explain the difference between .js and .min.js? : jquery mobile

569


Can we call C# code behind using jQuery?

659


What are the advantage of using minimized version of jquery?

574