jQuery one() Method
You are Here:
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.
Example
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>
Syntax
$(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. |
Reminder
Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in jQuery.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.