Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

jQuery select() Method

❮ jQuery Event Methods

Example

Alert a message when a text is selected in a text field:

$("input").select(function(){
  alert("Text marked!");
});
Try it Yourself »

Definition and Usage

The select event occurs when a text is selected (marked) in a text area or a text field.

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


Syntax

Trigger the select event for the selected elements:

$(selector).select() Try it

Attach a function to the select event:

$(selector).select(function) Try it

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

❮ jQuery Event Methods