English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery select() Method

jQuery Events

The select() method triggers the select event or attaches a function to be executed when the select event occurs.

A select event occurs when the user selects some text (such as <input>, <textarea>).

Syntax:

Trigger the selection event of the selected element:

$.select(selector)

Attach a function to the select event:

$.select(selector).select(function)

Example

Remind message when text is selected in the <input> field:

$("input").select(function() { 
  alert('Selected!!!');
});
Test and see‹/›

Trigger the select event of the <input> field:

$("button").click(function(){
  $("input").select();
});
Test and see‹/›

Parameter Value

ParameterDescription
functionFunction executed each time a select event is triggered

jQuery Events