jQuery select()Method

jQuery 事件方法jQuery Event Methods

Examples

When text in the text area is selected, display an alert message:

$("input").select(function(){
alert("Text selected!");
});

Try it Yourself »

Definition and Usage

The select event occurs when text within a textarea or an input element of type text is selected (highlighted).

The select() method triggers the select event, or specifies a function to run when the select event occurs.


Syntax

Trigger the select event for the selected element:

$(selector).select() Try it Yourself

Attach a function to the select event:

$(selector).select(function) Try it Yourself

Parameters Description
function Optional. Specifies the function to run when the select event is triggered.


jQuery 事件方法jQuery Event Methods

Other Extensions