Skip to content
Related Articles

Related Articles

HTML | onselect Event Attribute

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 16 Aug, 2022
View Discussion
Improve Article
Save Article

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>.

Supported Tags: 

  • <input type=”file”>
  •  <input type=”password”>
  •  <input type=”text”> 
  •  <textarea>


<element onselect = "script">



<!DOCTYPE html>
        <title>onselect event attribute</title>
            h1 {
            body {
            function Geeks() {
                alert("Text selected!");
        <h2>onselect event attribute</h2>
        Text Box: <input type="text" value="GeeksforGeeks: A computer
        science portal for geeks" onselect="Geeks()">


Supported Browsers: The browser supported by onselect attribute are listed below: 

  • Apple Safari 1
  • Google Chrome 1
  • Edge 12
  • Firefox 6
  • Opera 12.1
  • Internet Explorer 9
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!