Latest web development tutorials

onselect event

Event Object Reference Event objects

Examples

When the text is selected, execute a Javascript code:

<input type="text" onselect="myFunction">

try it"

Definition and Usage

onselect event occurs when the text in the text box is selected.

grammar

In HTML:

<element onselect="SomeJavaScriptCode">

In JavaScript:

object .onselect=function(){SomeJavaScriptCode}

参数 描述
SomeJavaScriptCode 必需。规定该事件发生时执行的 JavaScript。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support onselect event


HTML in the onselect

onselect property can be used: <input type = "file">, <input type = "password">, <input type = "text">, <keygen>, and <textarea>.


Event Object Reference Event objects