Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

HTML onselect Attribute


Definition and Usage

The onselect attribute fires after some text has been selected in an element.


Applies to

The onselect attribute is part of the Event Attributes, and can be used on any HTML elements.

Elements Event
All HTML elements onselect

Example

Input Example

Execute a JavaScript after some text has been selected in an <input> element:

<input type="text" onselect="myFunction()" value="Hello world!">
Try it Yourself »

Browser Support

Event Attribute
onselect Yes Yes Yes Yes Yes