The select event fires when the user highlights text inside a text input or textarea. Bind with .on("select", handler) (jQuery 1.7+). Merely placing the cursor does not fire it — at least one character must be selected.
Remember
$("#target").on("select", function () {
// user highlighted text inside the field
});
$("#other").on("click", function () {
$("#target").trigger("select"); // runs handlers + selects all text
});
// Not for HTML <select> dropdowns → use change
$("#country").on("change", handler);
Trigger with .trigger("select") to run handlers and select all text.
Read the highlight with selectionStart / selectionEnd (or getSelection()).
Do not use this for HTML <select> dropdowns — use change.
Piece
Required?
Role
Text field
Yes
input (text-like) or textarea
handler
For bind
function(event) — runs when text is highlighted
eventData
Optional
Extra data available as event.data
Highlight
Yes (user)
At least one character must be selected
Pseudocode
Pseudocode
call input.on("select", handler)
→ store handler on the field
when user highlights text (drag / double-click / Shift+arrow):
fire "select" on input
call handler(event)
when user only clicks to place caret:
select does NOT fire
call input.trigger("select")
→ run bound handlers
→ browser default: select all text in the field
to migrate shorthand:
.select(fn) → .on("select", fn)
.select() → .trigger("select")
Reference
Cheat Sheet
Keep these facts handy while wiring text-selection UX.
Topic
Detail
Bind
$("#el").on("select", handler)
Trigger
$("#el").trigger("select") (also selects all text)
Unbind
$("#el").off("select" [, handler])
Targets
Text input and textarea only
Not for
HTML <select> dropdowns → use change
vs change
Highlight vs value change
Since
.on("select") 1.7 · .trigger("select") 1.0
Legacy shorthand
.select() ⚠ deprecated for binding since 3.3
Read selection
el.selectionStart … el.selectionEnd
Try it
Live Preview
Highlight text in the demo field, or run an action to .trigger("select") (selects all).
Click-drag or double-click a word in the field below.
Result
Ready — highlight text or pick an action.
Code
jQuery Examples
Short, copy-ready snippets based on the official jQuery API demos. Open Try It Yourself for a live editor.
Example 1 — Basic .on("select")
Official pattern: run a handler when #target text is highlighted.
jQuery
$("#target").on("select", function () {
$("#out").text("Handler for select called.");
});
Highlight any characters in #target
#out shows "Handler for select called."
How It Works
Bind..on("select", fn) registers the callback.
Highlight. Drag or double-click to select text.
Fire. The browser sends the select event.
Caret-only. A plain click does not fire the event.
Example 2 — Trigger Select from a Button
Official pattern: #other calls .trigger("select") — handlers run and all text is selected.
jQuery
$("#target").on("select", function () {
$("#out").text("Select handler ran (user or trigger).");
});
$("#other").on("click", function () {
$("#target").trigger("select");
});
Highlight text in any matched input
#out shows which field fired select
How It Works
Select.:input matches form controls on the page.
Bind. Each field gets the same select handler.
Highlight. Selecting text in any of them fires the event.
Identify.this.id / this.name labels the source.
Example 4 — Show Selection Length
Use selectionStart and selectionEnd to measure the highlight.
jQuery
$("#notes").on("select", function () {
var start = this.selectionStart;
var end = this.selectionEnd;
var text = $(this).val().slice(start, end);
$("#out").text("Selected " + (end - start) + " char(s): " + text);
});
Check these before relying on select handlers in real UIs.
name
Not the HTML <select> element
Dropdown changes use change. The select event is for text highlights only.
caret
Cursor alone does not fire
Clicking to place the insertion point is not enough — highlight at least one character.
trigger
.trigger("select") selects all text
The default action selects the whole field. Expect that side effect in demos and UX.
shorthand
.select(handler) is deprecated
Prefer .on("select", handler). The shorthand bind form is deprecated since jQuery 3.3.
Compatibility
Browser Support
The select event is a standard DOM event on text fields. Bind with .on("select") since jQuery 1.7; .trigger("select") has existed since 1.0. Reading the selected string differs slightly by browser — use selectionStart/selectionEnd or getSelection().
✓ jQuery 1.7+
jQuery select event
Supported in all browsers jQuery targets for input/textarea. Prefer .on('select') / .trigger('select'). Not for HTML select dropdowns.
100%With jQuery loaded
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
selectExcellent
Bottom line: Safe for modern and legacy jQuery projects. Remember: text highlight only — use change for dropdowns.
Analysis
Performance Notes
Approach
Cost
Best for
Direct .on("select") on known fields
Cheap
Editors, copy helpers, toolbars
Reading selectionStart/End
Cheap
Character counts, snippets
Heavy work on every select
Expensive
Avoid — keep handlers light
Select can fire often while users adjust a highlight. Keep callbacks small — update a label or show a toolbar tip.
Remember
Key Takeaways
Role: react when the user highlights text in an input/textarea.
API:.on("select", fn) and .trigger("select").
Not dropdowns: HTML <select> uses change.
Trigger side effect:.trigger("select") selects all text.
One line: use select for text highlights in inputs/textareas — not for dropdown menus.
Frequently Asked Questions
The select event fires when the user makes a text selection inside an element — by click-dragging or double-clicking to highlight characters. It is limited to text inputs and textareas. Bind with .on("select", handler) since jQuery 1.7. Do not confuse it with the HTML <select> dropdown or the change event.
No. Placing the cursor (insertion point) alone does not trigger select. The user must highlight at least one character — click-drag, double-click a word, or Shift+arrow in supporting browsers.
It runs bound select handlers and also fires the browser default select action — typically selecting all text in the field. That is why the official jQuery demo selects the entire input when you click Trigger.
change fires when the field value changes. select fires when the user highlights existing text. You can select text without changing the value, and you can change a value without selecting text.
Common approaches: for inputs, use element.selectionStart and element.selectionEnd to slice .val(); or use window.getSelection() / document.getSelection().toString(). Browser details differ — many plugins wrap these APIs.
Prefer .on("select", handler) and .trigger("select"). The .select() shorthand binding form is deprecated since jQuery 3.3. See the .select() method tutorial for migration details.