jQuery select() with Examples

jQueryWeb DevelopmentFront End Technology

The select() method in jQuery is used to trigger the select event.


The syntax is as follows −


Above, the func parameter is used to specify the function to run when the select event is triggered. It occurs when a text is selected. The selection should be in a text area or a text field.

Let us now see an example to implement the jQuery select() method 


 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
         alert("You have selected some text...");
div {
   border: 3px dashed orange;
   background-color: gray;
   width: 400px;
   height: 100px;
   padding: 40px;
<input type="text" value="Demo text">


This will produce the following output −

On selecting any text in the input box, the following alert box will be visible −

Updated on 31-Dec-2019 09:17:59