Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

HTML onscroll Attribute


Definition and Usage

The onscroll attribute fires when an element's scrollbar is being scrolled.

Tip: use the CSS overflow style property to create a scrollbar for an element.


Applies to

The onscroll attribute is part of the Event Attributes, and can be used on any HTML elements.

Elements Event
All HTML elements onscroll

Example

Div Example

Execute a JavaScript when a <div> element is being scrolled:

<div onscroll="myFunction()">
Try it Yourself »

Browser Support

Event Attribute
onscroll Yes Yes Yes Yes Yes