jQuery one() Method

Last Updated:

jQuery one() Method

The jQuery one() method attaches a handler to an event for the elements. The handler is executed at most once per element per event type.


HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery one() Method</h1> <p>Click on this paragraph to increase its text size. The event will trigger only once.</p> <script> $(document).ready(function(){ $("p").one("click", function(){ $(this).css("font-size","+=5px"); }); }); </script> </body> </html>


$(selector).one(events, data, handler);

Parameter Values

Value Type Explanation
events Required Specifies a string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
data Optional Data to be passed to the handler in event.data when an event is triggered.
handler Required Specifies the function to run when the event occurs.

Browser Support

Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet

Share this Page

Meet the Author