HTML | onselect Event Attribute
The onselect event attribute works when some text has been selected in an element. It is the part of event attribute. It is supported by many HTML elements such as <input type = “file”>, <input type = “password”>, <input type = “text”>, and <textarea>.
Syntax:
<element onselect = "script">
Example:
<!DOCTYPE html> <html> <head> <title>onselect even attribute</title> <style> h1 { color:green; } body { text-align:center; } </style> <script> function Geeks() { alert("Text selected!"); } </script> </head> <body> <h1>GeeksforGeeks</h1> <h2>onselect event attribute</h2> Text Box: <input type="text" value="GeeksforGeeks: A computer science portal for geeks" onselect="Geeks()"> </body> </html> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by onselect attribute are listed below:
- Apple Safari
- Google Chrome
- Firefox
- Opera
- Internet Explorer
- HTML | DOM onselect Event
- HTML | onfocus Event Attribute
- HTML | onpaste Event Attribute
- HTML | ononline Event Attribute
- HTML | ondragenter Event Attribute
- HTML | onkeydown Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | onmouseout Event Attribute
- HTML | onmouseover Event Attribute
- HTML | onclick Event Attribute
- HTML | onoffline Event Attribute
- HTML | ontoggle Event Attribute
- HTML | ondrag Event Attribute
- HTML | onresize Event Attribute
- HTML | onreset Event Attribute
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



