jQuery select()

The jQuery select() method is used to attach a function to run when a select event occurs i.e. when a text is marked or selected in a text area or a text field. This method is used for input type=”text” fields and textarea boxes.


To trigger the select event for selected elements.


To add a function to the select event.



  • It is an optional parameter.
  • The function parameter specifies the function to run when the event occurs.


<!DOCTYPE html>
p {
color: cyan;
div {
color: turquoise;
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<p>Select the text on the box</p>
<input type="text" value="Hello guys!">
<input type="text" value="myfriends.org">
$( ":input" ).select(function() {
$( "div" ).text( "You selected some text" ).show().fadeOut( 1000 );
Please follow and like us:
Content Protection by DMCA.com