The select event fires when the user highlights text inside an <input> or <textarea> — not when they change the value, and not on dropdown <select> elements. This tutorial covers .on("select"), eventData, .trigger("select"), reading selected text, comparison with change and click, and the official jQuery API demos.
01
.on()
Bind handler
02
Highlight
Drag to select
03
.trigger()
Select all
04
input
+ textarea
05
vs change
Different
06
Since 1.7
Modern API
Fundamentals
Introduction
Rich text editors, copy-to-clipboard buttons, and formatting toolbars often need to know when the user highlights a word or phrase. The select event is the browser signal for “the user just selected text inside this field.”
The official jQuery API distinguishes the selectevent (bound with .on("select") since 1.7) from the deprecated .select()method. To programmatically run select handlers — and select all text in the field — use .trigger("select") since jQuery 1.0.
⚠️
Not the <select> dropdown
The jQuery select event is about text selection (highlighting characters). Dropdown menus use the change event when the user picks a new option. The similar names confuse beginners — this page covers text highlight only.
Concept
Understanding the select Event
The select event is sent to an element when the user makes a text selection inside it. It applies to text <input> fields and <textarea> boxes — not checkboxes, radios, or <select> dropdowns.
Placing the cursor without highlighting text does not fire select. The user must select one or more characters — typically by click-dragging, double-clicking a word, or using Shift+arrow keys. Each new selection inside the same field can fire the event again.
💡
Beginner Tip
When you call .trigger("select"), jQuery runs your handler and performs the default action — usually selecting all text in the input. That matches the official API demo where clicking Trigger highlights the entire field.
Foundation
📝 Syntax
The modern jQuery API for the select event has two main forms — binding a handler and triggering the event:
Four easily confused concepts — the select event is not the HTML element.
select event
highlight
User drags to highlight text in input or textarea — value may stay the same
change event
value diff
Committed value changed — use for dropdowns, checkboxes, and edited text on blur
click event
press
Mouse down+up on element — fires even when user only places cursor, no highlight
<select> element
dropdown
HTML dropdown menu — use .on("change") when user picks a new option
Hands-On
Examples Gallery
Examples 1–2 follow the official jQuery API documentation. Examples 3–5 extend the official :input demo, selected-text length display, and eventData. Use the Try-it links to run each snippet in the browser.
📚 Binding & Triggering
Official jQuery demos for select handlers and programmatic triggers.
Example 1 — Official Demo: Bind Handler on #target
Alert when the user highlights any portion of text in the input field.
Click-drag to highlight text in #target → alert runs
Click to place cursor only (no highlight) → no alert
Double-click a word → alert runs (word selected)
How It Works
.on("select", fn) registers on the text input. The handler runs when the browser fires select after the user highlights characters — not on every click or keystroke.
Example 2 — Official Demo: #other Triggers Select on #target
One button programmatically fires the select handler and selects all text in the field.
Highlight text manually → alert runs
Click #other → trigger("select") → alert runs again
Entire #target text becomes selected (default action)
How It Works
.trigger("select") synthetically fires the event and performs the default select-all behavior. Useful for “Select all” buttons that should run the same handler as manual highlighting.
📈 Practical Selection Patterns
Official extended demo, selection length, and formatting toolbar patterns.
Example 3 — Official Demo: :input Selection Notice
Bind on all inputs — show a fading message whenever text is selected in any field.
Highlight text in any input or textarea on the page
→ #notice shows "Something was selected", fades over 1s
Matches the official jQuery API Example 1 demo
How It Works
$(":input") matches text inputs, textareas, buttons, and other form controls — but select only fires meaningfully on text fields and textareas. Checkboxes and buttons ignore text selection.
Example 4 — Show Selected Character Count
Read selectionStart and selectionEnd to display how many characters the user highlighted.
jQuery
$( "#bio" ).on( "select", function() {
var el = this;
var len = el.selectionEnd - el.selectionStart;
var text = $( el ).val().substring( el.selectionStart, el.selectionEnd );
$( "#stats" ).text( len + " chars selected: "" + text + """ );
} );
Highlight "Hello" in textarea → "5 chars selected: "Hello""
#stats updates on each new selection
Cross-browser note: selectionStart/End work on inputs and textareas
How It Works
Native input elements expose selectionStart and selectionEnd — slice .val() between them for the highlighted substring. For complex pages, consider a plugin or document.getSelection().
Example 5 — Pass eventData to Show a Format Toolbar
Pass toolbar config via event.data — show bold/italic hints when text is selected.
Highlight text in textarea → #toolbar appears with event.data.toolbar
Click without selection → toolbar hides
Delegated select on #editor covers nested textareas
How It Works
Combines delegation, eventData, and selection length. Real rich-text editors use similar patterns — show formatting controls only when the user has highlighted text.
Applications
🚀 Common Use Cases
Copy / share selection — enable a “Copy quote” button when the user highlights text in a textarea.
Formatting toolbar — show bold, italic, or link controls when characters are selected.
Character limits — warn if the user selects more characters than a paste limit allows.
Analytics — log which phrases users highlight in feedback forms.
Select-all button — $("#field").trigger("select") runs handlers and selects all text.
Contextual help — show a definition popup for the highlighted word.
🧠 How the select Event Flows
1
User highlights text
Click-drag, double-click a word, or Shift+arrow keys inside an input or textarea.
drag
2
Browser fires select
Native select event sent to the field — cursor-only clicks do not qualify.
select
3
jQuery runs handler
Your .on("select", fn) callback executes — read selection via selectionStart/selectionEnd.
handler
4
✎
UI updates
Show toolbar, copy button, or selection stats. On .trigger("select"), default action also selects all text.
Important
📝 Notes
Bind with .on("select", handler) since jQuery 1.7 — not the deprecated .select(handler) method.
Trigger with .trigger("select") since jQuery 1.0 — also performs default select-all action.
Limited to text <input> and <textarea> — not <select> dropdowns.
Cursor placement alone does not fire select — user must highlight characters.
Getting selected text differs by browser — use selectionStart/selectionEnd on inputs or plugins for complex cases.
Not the same as the HTML <select> element — that uses change when options change.
Use .off("select") to remove handlers — avoid deprecated .unbind("select").
Compatibility
Browser Support
The select event is supported on text inputs and textareas in browsers jQuery targets. jQuery’s .on("select") (since 1.7) and .trigger("select") (since 1.0) work across jQuery 1.x, 2.x, and 3.x.
✓ jQuery 1.7+
jQuery select event
Supported in jQuery 1.x, 2.x, and 3.x across modern browsers. Native equivalent: element.addEventListener('select', fn) on inputs and textareas. Cross-browser selected-text retrieval may need helpers beyond the event itself.
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
selectUniversal
Bottom line: Safe in any jQuery project. Prefer .on('select') over deprecated .select() for binding. Remember: select event ≠ HTML
Wrap Up
Conclusion
The jQuery select event reacts when users highlight text inside inputs and textareas. Bind handlers with .on("select", fn), pass optional eventData, and fire handlers programmatically with .trigger("select") — which also selects all text by default.
Do not confuse this event with dropdown <select> elements or the change event. Use selectionStart and selectionEnd to read highlighted text, and consider plugins for advanced cross-browser selection APIs.
Bind with .on("select", handler) on inputs and textareas
Use selectionStart and selectionEnd to read highlighted text on inputs
Delegate on container elements for multiple textareas in an editor
Explain to teammates that select event ≠ HTML <select> dropdown
Use .trigger("select") for Select-all buttons that should run the same handler
❌ Don’t
Bind .on("select") on <select> dropdowns — use change
Expect select when the user only clicks to place the cursor
Assume the jQuery event object includes selected text on all browsers
Use deprecated .select(handler) in new code
Confuse text selection with value change — use change or input for edits
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about the select event
Highlight, not dropdown.
6
Core concepts
.on01
.on("select")
Bind
API
✎02
Highlight
Drag select
Trigger
⚡03
.trigger()
Select all
Programmatic
≠04
<select>
Not this
Confusion
len05
selectionStart
Read text
Native
.off06
.off("select")
Unbind
Cleanup
❓ Frequently Asked Questions
The select event fires when the user makes a text selection inside an element — by clicking and dragging the mouse to highlight characters. It is limited to text input fields and textareas. Bind handlers with .on('select', handler) since jQuery 1.7. Do not confuse it with the HTML <select> dropdown element or the change event on dropdowns.
No. Merely placing the cursor (the insertion point) inside a field does not trigger select. The user must highlight at least one character — click-drag or double-click a word. Keyboard Shift+arrow selection also fires select in supporting browsers.
Calling .trigger('select') runs bound select handlers and also fires the browser's default select action — typically selecting all text in the field. That is why the official jQuery demo selects the entire input when you click the Trigger button.
They measure different things. change fires when the field's value changes — picking a dropdown option or editing text and tabbing away. select fires when the user highlights a portion of existing text inside an input or textarea. You can select text without changing the value.
There is no single cross-browser property on the jQuery event object. Common approaches: document.getSelection().toString(), window.getSelection(), or for inputs specifically: element.selectionStart and element.selectionEnd to slice .val(). Many jQuery plugins wrap these differences.
The jQuery select event documentation limits the event to input fields and textareas. For contenteditable regions, use document.getSelection() with mouseup or selectionchange events instead.
Did you know?
When jQuery’s .trigger("select") runs, it invokes your handler and performs the browser default action — which for text inputs usually means selecting all text in the field. That is why the official API demo’s Trigger button both alerts and highlights the entire input. For handler-only execution without the default action, use .triggerHandler("select") instead.