Using JQuery, one can establish a function as an event handler for a given element with the bind() command or with shortcut commands for common events such as click() or change(). Once an event handler is established it will be exucuted anytime the event happens unless it is removed with the unbind() command.
There is however an alternative version of the bind() command in JQuery. The one() command establishes an event handler for a given elelment and removes it automatically once it has been executed. For example:
$('#logo').one('click', function(){
alert('clicked');
});Once a user clicks on the #example element, an alert will appear and the event handler will be removed and hence any subsequent clicks on the #example element will not show the allert.
Comments
Post new comment