|
|
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>.
|
<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.
<!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 |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Form Events Attribute |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference