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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("#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);
Call
What it does
Select
Learn the jQuery select event: bind with .on(\
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Bind with .on("select", handler) on an input or textarea.
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.
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.
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.