Easy learning with example program codes

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 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=""></script>  
 <p>Select the text on the box</p>  
  <input type="text" value="Hello guys!">  
  <input type="text" value="">  
$( ":input" ).select(function() {  
  $( "div" ).text( "You selected some text" ).show().fadeOut( 1000 );  

Try it

JS Bin on

Please follow and like us:

Copyright © 2020 CodesJava Protection Status