jQuery select() Method

jQuery select() event occurs when a text is selected in a text field or textarea. The jQuery select method triggers the select event, and when select event occurs specified function will execute.

Syntax

This syntax represent to the select() method

$(selector).select();        // This syntax does not accept any arguments.

and this syntax represent to attach a function to the select event

$(selector).select(function);
Parameter Type Description
function Function Optional. Specifies the function to execute when the select is occurs

Examples

This example represent the select event

$(document).ready(function(){
  $("input").select(function(){
    $("span").text("Text Selected");
  });
  $("button").click(function(){
    $("input").select();
  });
});

Run it...   »


This example represent to attach a function to the select event.

$(document).ready(function(){
  $("input").select(function(){
    $("span").text("Text Selected");
  });
});

Run it...   »