![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery select() with Examples
The select() method in jQuery is used to trigger the select event.
syntax
The syntax is as follows −
$(selector).select(func)
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 −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").select(function(){ alert("You have selected some text..."); }); }); </script> <style> div { border: 3px dashed orange; background-color: gray; width: 400px; height: 100px; padding: 40px; } </script> </style> </head> <body> <div> <input type="text" value="Demo text"> </div> </body> </html>
Output
This will produce the following output −
On selecting any text in the input box, the following alert box will be visible −
Advertisements