Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




EVENTS - select()


The select() Event gets executed, when the contents of a field (Like an text or textarea field) is selected.


Let us simplify with the below example.


Example :



<html>
  	<head>
    	<title> My First Programme </title>
  	</head>

  	<body>
    	<h1> JQuery </h1>
    		
    	Type Something and select the typed text : <input type = "text"> 	
        
        <p> </p>

      	<script src = "https://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script>
	  
      	<script>
      
			$('input').select( function() { 
            	$('p').text("You have selected the text in the input field")
            });
            
      	</script>      
  	</body>
</html>  


Output :



So, if you look at the above code, we have an <input> element, that accepts a text.


<input type = "text">

And we have an empty <p> element.


Now, if we take a look at the JQuery statement,


$('input').select( function() {
	$('p').text("You have selected the text in the input field")
});

That locates the <input> element and when you select the text inside the text inside the <input> field, the select() event gets triggered.


$('input').select(...);

And the anonymous function gets executed.


function() {
	$('p').text("You have selected the text in the input field")
}

Displaying the text in <p> element as You have selected the text in the input field.