jQuery .select() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Form Events

Definition

.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);
CallWhat it does
handlerfunction(event) — runs when text is highlighted
eventDataExtra data available as event.data
No-arg callFires select + selects all text
Text fieldinput (text-like) or textarea

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Bind with .select(handler) (legacy) or .on("select", handler) (preferred).
Step 2Optionally pass eventData: .select(data, handler) → .on("select", data, handler).
Step 3Trigger with no-arg .select() (legacy) or .trigger("select") (preferred) — selects all text.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Basic .select(handler)

Legacy bind: run a handler when #target text is highlighted.

jQuery
$("#target").select(function () {
  $("#out").text("Handler for select called (.select(fn)).");
});
Try It Yourself

How It Works

  1. Bind. .select(fn) registers the callback (deprecated).
  2. Highlight. Drag or double-click to select text.
  3. Fire. The browser sends the select event.

Example 2 — .select(eventData, handler)

Pass metadata (since 1.4.3). Modern form: .on("select", data, fn).

jQuery
$("#notes").select({ tip: "Copy / Bold / Link" }, function (event) {
  $("#out").text("Toolbar: " + event.data.tip);
});
Try It Yourself

How It Works

  1. Data. The object becomes event.data.
  2. Select. Highlighting text fires the handler.
  3. Tip. Read event.data.tip for UI context.

Example 3 — No-Arg .select() Trigger

No arguments means trigger — same as .trigger("select") (selects all text).

jQuery
$("#target").select(function () {
  $("#out").text("Select handler ran (user or .select()).");
});

$("#other").on("click", function () {
  $("#target").select(); // no-arg → trigger
});
Try It Yourself

How It Works

  1. Bind. A select handler is ready on #target.
  2. Click. The button calls no-arg .select().
  3. 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.

Next: Submit Event

Learn how to bind handlers when the user submits a form.

Submit Event tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful