Javascript examples for jQuery Method and Property:select
The select() method triggers the select event, or sets function to run when a select event occurs.
Parameter | Require | Description |
---|---|---|
function | Optional. | function to call when the select event is triggered |
The following code shows how to Alert a message when a text is selected in a text field:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input").select(function(){ console.log("Text marked!"); });// www .j a v a2 s. c o m }); </script> </head> <body> <p>Select some text inside the input field.</p> <input type="text" value="Hello World"> </body> </html>