/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onscroll

[this page | pdf | back links]

The HTML onscroll attribute specifies the event that is triggered when the element’s scrollbar is being scrolled. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
onscroll: try scrolling within this textarea
<textarea type="text" name="textareainput" width = "100px" rows="1" onscroll="myOnscroll()">
An example of an element with scrolling
</textarea><br>

<script>
function myOnscroll() {alert("Element being scrolled");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile