Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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