Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

jQuery select()

jQuery select event occurs when a text is marked or selected in text area or a text field. This event is limited to <input type=”text”> fields and <textarea> boxes. When the select event occurs, the select() method attaches a function to run.


  1. $(selector).select()

It triggers the select event for selected elements.

  1. $(selector).select(function)

It adds a function to the select event.

Parameters of jQuery select() event

Parameter Description
Function It is an optional parameter. It is used to specify the function to run when the select event is executed.

Example of jQuery select() event

Let’s take an example to demonstrate jQuery select() event.

  1.  <!doctype html>
  2. <html lang=“en”>
  3. <head>
  4.   <meta charset=“utf-8”>
  5.   <title>select demo</title>
  6.   <style>
  7.   p {
  8.     color: red;
  9.   }
  10.   div {
  11.     color: blue;
  12.   }
  13.   </style>
  14.   <script src=“”></script>
  15. </head>
  16. <body>
  17.  <p>Select the text on the box: click and drag the mouse to select text.</p>
  18.   <input type=“text” value=“”>
  19.   <input type=“text” value=“”>
  20.   <div></div>
  21.  <script>
  22. $( “:input” ).select(function() {
  23.   $( “div” ).text( “Some text was selected” ).show().fadeOut( 2000 );
  24. });
  25. </script>
  26.  </body>
  27. </html>

Test it Now


Select the text on the box: click and drag the mouse to select text.