jQuery Tutorial Tutorials - jQuery .one() method

jQuery .one() method

The .one() method in jQuery is used to attach an event handler to the selected elements. The handler is executed at most once per element per event type.

jQuery .one() method Syntax

.one(events[,selector][,data],handler)
Parameter Type Description
events String A string contain space-separated event types and optional namespacessuch as click,submit,keydown.myPlugin.
handler Function event handler function to execute when the event is triggered. It's executed at most one time per element per event type.
selector String A selector used to filter selected elements that trigger the event
data Anything Data to be passwd to the handler

jQuery .one() method Example

example

event type is unbound after the handler's first invocation for a given element.

$( "p" ).one( "click", function() {
  alert( $( this ).text() );
});

Try now

Date:2019-08-29 23:48:35 From:www.Lautturi.com author:Lautturi