<html> <head> <script type="text/javascript"> function message() { alert("This alert box was triggered when you selected the content of the input field"); } </script> </head> <body> <p>Select the content in the input field</p> <form> <input type="text" value="Select this text" onselect="message()" size="20"> </form> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself