.select() is jQuery’s legacy shorthand for binding or triggering the select event — when the user highlights text inside an input or textarea. Binding is deprecated since 3.3; modern code uses .on("select") / .trigger("select"). It is not the HTML <select> dropdown.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Legacy (still works; bind form deprecated since 3.3)
$("#target").select(function () {
// user highlighted text inside the field
});
// Modern replacements
$("#target").on("select", handler); // bind
$("#target").trigger("select"); // fire + select all text
// Not for HTML <select> dropdowns → use change
$("#country").on("change", handler);
Call
What it does
handler
function(event) — runs when text is highlighted
eventData
Extra data available as event.data
No-arg call
Fires select + selects all text
Text field
input (text-like) or textarea
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Bind with .select(handler) (legacy) or .on("select", handler) (preferred).
Click #other → entire field selected
Bound handler updates #out
How It Works
Bind. A select handler is ready on #target.
Click. The button calls no-arg .select().
Default. The browser selects all text in the field.
Frequently Asked Questions
The .select() method has two roles. With a handler — .select(handler) or .select(eventData, handler) — it binds a function that runs when the user highlights text inside an input or textarea. With no arguments — .select() — it triggers the select event, running bound handlers and typically selecting all text. Binding has been part of jQuery since 1.0 and is deprecated since 3.3. Do not confuse this with HTML <select> dropdowns.
Yes. The binding signatures .select(handler) and .select(eventData, handler) are deprecated since jQuery 3.3. Use .on("select", handler) instead. The no-argument .select() trigger still works, but .trigger("select") is clearer. Legacy code continues to run in jQuery 3.x.
.select(handler) registers a callback and does not fire immediately. .select() with no arguments triggers the select event — the same as .trigger("select") — and usually selects all text in the field. Check whether parentheses contain a function before reading legacy code.
Replace .select(fn) with .on("select", fn). Replace .select(data, fn) with .on("select", data, fn). Replace no-arg .select() with .trigger("select"). Cleanup with .off("select"). Under the hood, .select(handler) already delegates to .on("select").
No. jQuery .select() is shorthand for the select event — text highlighting inside inputs and textareas. HTML <select> dropdowns use the change event when the user picks an option.
No. Direct .select(fn) only binds to elements that already match. For dynamic fields, use .on("select", "input", fn) on a parent. That is one reason to prefer .on() over the shorthand.