jQuery one() is a function which provides single-use event handling. By single-use I mean that the event will be executed/handled only once.
For Example:
$('YOUR_SELECTOR').one('click', function(){
alert('1. This message will be displayed only once.');
});
http://api.jquery.com/one/
Interestingly the same functionality can be executed by jQuery on() function , as follows:
$('YOUR_SELECTOR').on("click", function(event) {
alert('2. This message will be displayed only once.');
$(this).off(event);
});
http://api.jquery.com/on/
Thank You,
For Example:
$('YOUR_SELECTOR').one('click', function(){
alert('1. This message will be displayed only once.');
});
http://api.jquery.com/one/
Interestingly the same functionality can be executed by jQuery on() function , as follows:
$('YOUR_SELECTOR').on("click", function(event) {
alert('2. This message will be displayed only once.');
$(this).off(event);
});
http://api.jquery.com/on/
Thank You,
No comments:
Post a Comment