html tutorial - onselect Attribute in HTML - html5 - html code - html form

Onselect attribute in html

Learn html - html tutorial - Onselect attribute in html - html examples - html programs

  • The onselect attribute specifies after a part of text has been selected in the element.
  • onselect attribute is a part of the Event Attributes.

Syntax for onselect attribute in HTML:

<element onselect=ā€¯script">

Applies To:

Element Attribute
All HTML Element onselect

Attribute Values:

Value Description
script The script can run on onselect

Sample Coding for onselect Attribute in HTML:

Tryit<!DOCTYPE html>
         <title>Wikitechy onselect attribute</title>
    <body>Enter the text: 
      <input type="text" value="Wikitechy tutorials!!" onselect="onSelect()">
      function onSelect() 
        alert("You are selected the Wikitechy tutorials!");

Code Explanation for onselect Attribute in HTML:

onselect Attribute Code Explanation

  1. The onselect attribute is used to call the onSelect() JavaScript function when the user try to select the text in the textbox.
  2. The onSelect() function used to display an alert message.

Output for onselect Attribute in HTML:

onselect Attribute Tag Output

  1. The term Wikitechy tutorials!! is displayed which can be selected.
  2. After selecting the Wikitechy tutorials!! the alert box has been displayed with the message "You are selected the Wikitechy tutorials!".

Browser Support for onselect Attribute in HTML:

Yes Yes Yes Yes Yes

Related Searches to onselect Attribute in html