![]() |
The
onselect
event attribute in HTML triggers a script when a user selects some text within an element. It is part of the Event Attributes and is primarily used with text-based input elements like
<input type="text">
and
<textarea>
. |
Example:
HTML
<input type="text" onselect="myFunction()" value="Hello world!">
The onselect attribute fires after some text has been selected in an element.
< element onselect=" script ">
Value | Description |
---|---|
script | The script to be run on onselect |
Supported HTML tags: | <input type="file">, <input type="password">, <input type="text">, and <textarea> |
---|
The function myFunction() is triggered when some text is selected in the input field. The function shows a message.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
Some text: <input type="text" value="Select me!!" onselect="myFunction()">
<p>The function myFunction() is triggered when some text is selected in the input field. The function shows a message.</p>
<script>
function myFunction() { alert("You have selected some text!");
}
</script>
</body>
</html>
html event attributes |
List of Form Events Attribute | HTML Form Events Attribute |
HTML onblur Event Attribute | HTML Form Events Attribute |
HTML onchange Event Attribute | HTML Form Events Attribute |
HTML oncontextmenu Event Attribute | HTML Form Events Attribute |
HTML onfocus Event Attribute | HTML Form Events Attribute |
HTML oninput Event Attribute | HTML Form Events Attribute |
HTML oninvalid Event Attribute | HTML Form Events Attribute |
HTML onreset Event Attribute | HTML Form Events Attribute |
HTML onsearch Event Attribute | HTML Form Events Attribute |
HTML onselect Event Attribute | HTML Form Events Attribute |
HTML onsubmit Event Attribute | HTML Form Events Attribute |
Example of HTML onselect Event Attribute | HTML Form Events Attribute |
Definition and Usage of HTML onselect Event Attribute | HTML Form Events Attribute |
Browser Support of HTML onselect Event Attribute | HTML Form Events Attribute |
Syntax of HTML onselect Event Attribute | HTML Form Events Attribute |
Attribute Values of HTML onselect Event Attribute | HTML Form Events Attribute |
Technical Details of HTML onselect Event Attribute | HTML Form Events Attribute |
How to add a JavaScript after some text has been selected in an <input> element | HTML Form Events Attribute |
Type
: |
Develop |
Category
: |
Web Tutorial |
Sub Category
: |
HTML Form Events Attribute |
Uploaded by
: |
Admin |
Read Article https://horje.com/learn/1434/reference