.one(events [, selector] [, data], handler) is like .on(), except the handler is unbound after its first run on that element for that event type (since 1.1; full .on()-style signatures since 1.7).
Remember
$("#foo").one("click", function () {
alert("This will be displayed only once.");
});
// Equivalent idea:
$("#foo").on("click", function (event) {
alert("This will be displayed only once.");
$(this).off(event);
});
Use the same patterns as .on() when you only want the first fire.
Select the element(s) that should react once.
Call .one(events, handler) (or with selector / data like .on()).
First matching event runs the handler.
jQuery unbinds that handler for that element and event type.
Further matching events on that element do nothing for that binding.
Form
Since
Role
.one(events [, data], handler)
1.1
Direct one-shot bind
.one(events [, selector] [, data], handler)
1.7
Delegated one-shot bind
.one(eventsMap [, selector] [, data])
1.7
Object map of event → handler
Pseudocode
Pseudocode
attach handler like .on(...)
when EVENT fires on ELEMENT (or matching descendant):
run HANDLER once
unbind this handler for ELEMENT + EVENT type
later same EVENT on same ELEMENT:
this binding does not run again
note:
multiple event types → once per type
Reference
Cheat Sheet
Quick facts for one-shot handlers.
Topic
Detail
Returns
jQuery (chainable)
Since
1.1 · delegation / map 1.7
Limit
Once per element per event type
vs .on()
Same API, auto-unbind after first run
Multi-type
Each listed type gets its own “once”
Per element
Each matched element has its own counter
Remove early
Still possible with .off() before it fires
Try it
Live Preview
Click the target once — then again. Compare with a normal .on() bind.
Run a bind style, then click / hover the target.
Log
Ready — Run “one”, then click Target twice.
Code
jQuery Examples
Short, copy-ready snippets. Prefer .one() over manual .off(event) for simple one-shot cases.
Example 1 — One-Time Click
First click runs the handler; later clicks do nothing.
jQuery
$("#foo").one("click", function () {
$("#out").text("Fired once — click again does nothing.");
});
First click → message updates
Second click → no change from this handler
How It Works
Bind..one("click", …) attaches a temporary handler.
First. The click runs your function.
Unbind. jQuery removes that click handler automatically.
Later. Further clicks find nothing from this binding.
Example 2 — Once Per Element
Each matched element gets its own independent one-shot.
jQuery
var n = 0;
$(".box").one("click", function () {
var index = $(".box").index(this);
$("#out").text(
"Box #" + index + " clicked. Total unique: " + (++n)
);
});
Both buttons fire only on first click
Second clicks do nothing
How It Works
One. Auto-removes after the first run.
Manual..off(event) removes the current event’s handlers on this.
Same effect. Both patterns are one-shot for that type.
Prefer..one() when you do not need custom cleanup logic.
Edge Cases & Pitfalls
Common surprises with one-shot handlers.
types
Multi-type ≠ once total
.one("click mouseenter", fn) can still run twice — once per type.
elements
Each element has its own “once”
Clicking box A does not spend box B’s one-shot handler.
trigger
.trigger() also spends the shot
A programmatic trigger counts as the first invocation and unbinds afterward.
rebinding
Need another shot? Bind again
Call .one() again (or use .on()) if the action should be allowed later.
Compatibility
Browser Support
.one() has been part of jQuery since 1.1 (delegation and events-map forms since 1.7). It works wherever your loaded jQuery version runs.
✓ Stable · jQuery 1.1+
.one()
Works in every browser that runs your loaded jQuery version. Prefer a current jQuery 3.x build for modern projects.
100%With jQuery events
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: Production-ready. Use .one() for first-interaction handlers; use .on() when the handler must keep firing.
Analysis
Performance Notes
Approach
Cost
Best for
.one() on a few elements
Tiny
First-click / init-on-interact
Leaving forever .on() you meant once
Extra work on later events
Prefer .one() to auto-clean
Many one-shots on huge lists
Higher bind cost
Consider one delegated .on() with a “done” flag
.one() is cheap and self-cleaning. For thousands of items, one delegated handler with your own “already handled” check can be leaner.
Remember
Key Takeaways
Role: attach a handler that auto-removes after its first run.
Scope: once per element per event type — not once for the whole page.
API: same shapes as .on() (direct, delegated, data, maps).
Equiv:.on() + $(this).off(event) after the first run.
One line:.one() is .on() that unbinds itself after the first fire.
Frequently Asked Questions
.one() attaches a handler that runs at most once per matched element per event type. After the first run, jQuery unbinds that handler automatically. Signatures match .on() (including delegation since 1.7).
.on() keeps the handler until you .off() it. .one() removes it after the first invocation on that element for that event type.
Yes for a single event type. $("#foo").one("click", fn) is equivalent to binding with .on("click", …) and calling $(this).off(event) inside after the first run.
With .one("click mouseenter", fn), the handler can run once for click and once for mouseenter on the same element — once per type, not once total.
Yes since 1.7: .one(events, selector, handler). The once-limit applies to the element you called .one() on (the root). After the first matching descendant event, that delegated binding is spent for that event type.
First-click tutorials, one-time confirms, lazy init on first interaction, or any handler you would remove immediately after it runs. Use .on() when it must keep firing.