The .one() method attaches event handlers that run at most once per element per event type, then automatically unbind. It mirrors .on() in every signature — direct binding, delegation, eventData, and event maps — but saves you from manually calling .off(event) inside the handler.
01
Syntax
Same as .on()
02
Once
Auto-unbind
03
Per type
Per event type
04
Delegate
Since 1.7
05
eventData
Pass to handler
06
Since 1.1
Core API
Fundamentals
Introduction
Most event handlers should keep listening — every button click saves a form, every keystroke filters a list. But sometimes you only need a handler to fire once: a welcome tooltip on first hover, a one-time confirmation, or an initialization step triggered by the user’s first interaction.
jQuery’s .one() method (available since 1.1, with delegation added in 1.7) attaches a handler and removes it automatically after the first invocation on each matched element. It is the concise alternative to writing .on() followed by $(this).off(event) inside the callback.
Concept
Understanding .one()
When you call $("#foo").one("click", handler), jQuery registers the handler exactly like .on(). The difference appears after the first click on #foo: jQuery detaches that handler. A second click does nothing unless you bind again.
If you bind .one("click mouseenter", fn) with two event types, the handler can run up to twice on the same element — once for the first click and once for the first mouseenter. The limit is once per event type per element, not once total.
💡
Beginner Tip
Think of .one() as .on() with built-in cleanup. If your handler ends with $(this).off(event), replace the whole pattern with .one() for cleaner, self-documenting code.
Foundation
📝 Syntax
Three signatures from the official jQuery API:
1. Direct binding — .one( events [, data ], handler )since 1.1
jQuery
.one( events [, data ], handler )
2. With delegation — .one( events [, selector ] [, data ], handler )since 1.7
jQuery
$( "#list" ).one( "click", "li", function() {
alert( "First click on this li only!" );
} );
$( "div" ).one({
click: function() { /* runs once */ },
mouseenter: function() { /* runs once per type */ }
});
Equivalent manual pattern
jQuery
// .one() shorthand
$( "#foo" ).one( "click", function() {
alert( "This will be displayed only once." );
});
// Explicit .on() + .off(event) — same effect
$( "#foo" ).on( "click", function( event ) {
alert( "This will be displayed only once." );
$( this ).off( event );
});
Return value
Returns the original jQuery object for chaining.
Accepts false as handler shorthand (same as .on()).
Cheat Sheet
⚡ Quick Reference
Goal
Code
One-time click
$("#btn").one("click", fn)
Two event types, once each
$("#x").one("click mouseenter", fn)
Delegated one-time click
$("#list").one("click", "li", fn)
Pass data to handler
$("p").one("click", { id: 1 }, fn)
Multiple events via object
$("div").one({ click: fn1, mouseenter: fn2 })
Added in
jQuery 1.1 (delegation 1.7)
Compare
📋 .one() vs .on() vs manual .off(event)
Three ways to handle a single-use event. Prefer .one() when the handler should auto-remove after the first run.
.one()
Auto-unbind
Cleanest for one-shot handlers — recommended
.on()
Repeats
Handler stays until you call .off()
.on + .off
Manual
Same as .one() but more verbose
.off()
Remove
Explicit unbind — pair with .on()
Hands-On
Examples Gallery
All five examples follow the official jQuery API documentation for .one(). Try clicking repeatedly to see handlers fire only once per element or event type.
📚 Official API Examples
Five patterns from api.jquery.com/one/.
Example 1 — One-Time Alert on Click
The canonical introduction: bind a click handler that alerts once, then never fires again.
jQuery
$( "#foo" ).one( "click", function() {
alert( "This will be displayed only once." );
});
First click on #foo → alert appears
Second click → nothing (handler removed)
Same as .on("click", fn) + $(this).off(event)
How It Works
jQuery registers the handler, runs it on the first click, then removes it from the internal event registry for that element and event type.
Example 2 — One-Time Click on Each Green Square
Official interactive demo: each div responds to its first click independently, updating a counter.
jQuery
var n = 0;
$( "div" ).one( "click", function() {
var index = $( "div" ).index( this );
$( this ).css({
borderStyle: "inset",
cursor: "auto"
});
$( "p" ).text( "Div at index #" + index + " clicked." +
" That's " + (++n) + " total clicks." );
});
Click square 0 → "Div at index #0 clicked. That's 1 total clicks."
Click square 1 → counter increments; square 0 ignores further clicks
Each div: one handler, one response
How It Works
.one() binds separately to each matched div. Clicking square A does not consume square B’s one allowed click. Visual feedback (inset border) persists after the handler is removed.
Example 3 — Alert Paragraph Text on First Click Only
Official pattern: show each paragraph’s text in an alert the first time it is clicked.
First mouseenter → alert "The mouseenter event happened!" count=1
First click → alert "The click event happened!" count=2
Second mouseenter or click → nothing
How It Works
Multiple types in one string create separate one-shot bindings internally. The handler can fire up to two times on the same element — once per listed type.
Example 5 — Delegated One-Time Click on List Items
Since jQuery 1.7, .one() supports delegation — each li can be clicked once even when items are added dynamically.
jQuery
$( "#list" ).one( "click", "li", function() {
$( this ).addClass( "visited" ).text( "Visited once: " + $( this ).text() );
});
// New items added later still get one click each
$( "#add" ).on( "click", function() {
$( "#list" ).append( "
Click li → "visited" styling, text updated once
Click same li again → no change
Add new li via button → first click works, second ignored
How It Works
Delegation with .one() tracks one invocation per matching descendant per event type. Dynamic items participate without rebinding — ideal for “mark as read on first view” patterns.
Applications
🚀 Common Use Cases
First-click tutorials — show a hint the first time a user clicks a feature button.
One-time confirmations — “Are you sure?” dialog bound with .one("click", confirmFn).
Lazy initialization — load heavy resources on first user interaction instead of page load.
Mark-as-read — delegated .one("click", "li", markRead) on notification lists.
Intro animations — play a welcome animation once per section on first scroll or hover.
jQuery stores the handler with a special flag indicating it should be removed after the first successful invocation on each element.
Bind
2
Event fires
The browser triggers the event; jQuery delivers it to your handler with the normalized event object and correct this context.
Run
3
Auto .off()
After your handler returns, jQuery removes that binding for the specific element and event type — equivalent to $(this).off(event).
Remove
4
✅
Silent on repeat
Further events of that type on the same element are ignored unless you bind again with another .one() or .on() call.
Important
📝 Notes
.one() has existed since jQuery 1.1; delegation support arrived in 1.7 alongside .on().
Space-separated event types mean once per type, not once total — .one("click mouseenter", fn) can run twice on the same element.
Explicitly calling .off() from within a regularly-bound handler has the same effect as using .one() for a single type.
Delegated .one() does not work for SVG elements (same limitation as .on() delegation).
Non-bubbling events (scroll, load, error on some elements) cannot use delegation with .one() either.
To re-enable after the one shot, call .one() or .on() again in your handler or elsewhere.
Compatibility
Browser Support
.one() is a jQuery method available since jQuery 1.1 (delegation since 1.7) in all jQuery 1.x, 2.x, and 3.x releases. It works in every browser your jQuery version supports. Native equivalent: attach with addEventListener and call removeEventListener inside the handler.
✓ jQuery 1.1+
jQuery .one()
Supported in jQuery 1.1+ (delegation 1.7+) across all modern browsers and IE with supported jQuery builds. Safe for all jQuery projects that use .on().
100%Core jQuery API
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.one()Universal
Bottom line: Use .one() whenever a handler should fire once per element per event type. Pair with .on() for repeating handlers and .off() for manual removal.
Wrap Up
Conclusion
jQuery .one() is the concise API for one-shot event handlers. It shares every signature with .on() but automatically cleans up after the first run on each element and event type — no manual .off(event) required.
Reach for .one() when the handler’s job is inherently single-use. Keep .on() for repeating interactions and .off() when you need explicit, conditional, or namespace-based removal.
Use .one() instead of .on() + .off(event) for clarity
Remember the limit is once per event type when using multiple types
Use delegated .one() for one-time actions on dynamic list items
Re-bind with .one() if the user should get another one-shot later
Namespace handlers when mixing .one() and .off() in plugins
❌ Don’t
Expect one total firing when you pass "click mouseenter" — that is two allowed fires
Use .one() for handlers that must repeat every click
Confuse .one() with .trigger() — triggering does not consume the binding until a real handler run
Delegate non-bubbling events like scroll with .one()
Forget that each element in a collection gets its own one-shot handler
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .one()
One-shot handlers made simple.
6
Core concepts
1×01
Once
Per element.
Core
=02
Like .on()
Same syntax.
API
type03
Per type
Multi-event.
Rule
off04
Auto-off
No manual .off.
Cleanup
li05
Delegate
Since 1.7.
Dynamic
1.106
Stable
Core API.
Status
❓ Frequently Asked Questions
.one() attaches an event handler that runs at most once per matched element per event type. After the first invocation, jQuery automatically unbinds that handler. It accepts the same signatures as .on() — direct binding, delegation, eventData, and event maps.
.one() is identical to .on() except the handler is removed after its first run on each element. Calling .on('click', fn) keeps the handler forever; .one('click', fn) removes it after the first click on that element.
Yes, for a single event type. $('#foo').one('click', fn) is equivalent to $('#foo').on('click', function(event) { fn.apply(this, arguments); $(this).off(event); }). Using .one() is shorter and clearer for one-shot handlers.
If you pass space-separated types like .one('click mouseenter', fn), the handler runs once per event type per element. A hover could fire on mouseenter once and on click once — up to two total invocations on the same element.
Yes. Since jQuery 1.7, .one(events, selector, handler) delegates like .on(). Each matching descendant can trigger the handler once per event type. Useful for one-time interactions on dynamically added elements.
Use .one() for initialization-on-first-interaction, one-time confirmations, first-click tutorials, or any handler you would otherwise remove with .off(event) after the first run. Use .on() when the handler should keep firing.
Did you know?
When jQuery 1.7 added delegation to .one(), it completed parity with .on(). Under the hood, a one-shot handler is implemented as a regular binding that calls .off(event) after execution — which is why the docs describe .one() as identical to .on() except for automatic removal.