/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onselect

[this page | pdf | back links]

The HTML onselect attribute specifies the event that is triggered when an element gets selected. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
onselect: try selecting some of the text within this input box:
<input type="text" value="Select some text" onselect="myOnselect()"><br>

<script>
function myOnselect() {alert("Some text has been selected");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile