English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
onselect is used to get or set the event handler function for the select event of the current window
Execute JavaScript after selecting some text in the <input> element
<!DOCTYPE html> <html> <head> <title>HTML onselect event attribute usage (Basic Tutorial Website oldtoolbag.com)</title> <script> function showMsg() { alert("You have selected some text information!"); } </script> </head> <body> Some text: <input type="text" value="Select me!!" onselect="showMsg()"> <p>showMsg() function is triggered when text information in the input field is selected. The function pops up some information./p> </body> </html>Test See ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the onselect event attribute
The onselect attribute is triggered when some text is selected in the element.
The onselect attribute can be used with the following elements: <input type="file">, <input type="password">, <input type="text">, <keygen>, and <textarea>.
No difference.
<element onselect="script">
Value | Description |
---|---|
script | Specifies the script to be executed when the onselect event is triggered. |