Horje

How to add a JavaScript after some text has been selected in an <input> element

The function myFunction() is triggered when some text is selected in the input field. The function shows a message.

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

Output should be:

How to add a JavaScript after some text has been selected in an <input> element




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Form Events Attribute
Uploaded by:
Admin