jQuery one()Method
Examples
When the <p> element is clicked, increase the text size of that element (each <p> element can only trigger the event once):
$("p").one("click",function(){
$(this).animate({fontSize:"+=6px"});
});
$(this).animate({fontSize:"+=6px"});
});
Try it yourself »
Definition and Usage
The one() method adds one or more event handlers to the selected elements and specifies a function to run when the event occurs.
When using the one() method, each element can only runoncethe event handler function.
Syntax
$(selector).one(event,data,function)
| Parameter | Description |
|---|---|
| event | Required. Specifies one or more events to add to the element. Separate multiple event values with spaces. Must be valid events. |
| data | Optional. Specifies additional data to pass to the function. |
| function | Required. Specifies the function to run when the event occurs. |
Other Extensions
jQuery Event Methods