jQuery Event - one() Method

Example

Increase the text size of the element when the p element is clicked:

$("p").one("click",function(){
  $(this).animate({fontSize:"+=6px"});
});

Try It Yourself

Definition and Usage

The one() method attaches one or more event handlers to the selected elements and specifies the function to be executed when the event occurs.

When using the one() method, each element can only run the event handler function once.

Syntax

$().one(event,data,function)
Parameters Description
event

Required. Specifies one or more events to be added to the element.

Multiple events separated by spaces. Must be valid events.

data Optional. Specifies additional data to be passed to the function.
function Required. Specifies the function to be executed when an event occurs.