Featured Post

Jquery one event

Returns: jQuery
.one(eventType, [eventData], handler(eventObject))
eventType A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
eventData A map of data that will be passed to the event handler.
handler(eventObject) A function to execute at the time the event is triggered.
Attach a handler to an event for the elements. The handler is executed at most once per element.
This method is identical to .bind(), except that the handler is unbound after its first invocation. For example:

$("#foo").one("click", function() {
alert("This will be displayed only once.");
});
After the code is executed, a click on the element with ID foo will display the alert. Subsequent clicks will do nothing. This code is equivalent to:

$("#foo").bind("click", function( event ) {
alert("This will be displayed only once.");
$(this).unbind( event );
});
In other words, explicitly calling .unbind() from within a regularly-bound handler has exactly the same effect.

If the first argument contains more than one space-separated event types, the event handler is called once for each event type.

Example Demo < 1 >
Tie a one-time click to each div.













Click a green square...




Comments

Popular posts from this blog

[Inside AdSense] Understanding your eCPM (effective cost per thousand impress...