Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML onscroll Event Attribute

❮ HTML Event Attributes

Example

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

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

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.


Browser Support

Event Attribute
onscroll Yes Yes Yes Yes Yes

Syntax

<element onscroll="script">

Attribute Values

Value Description
script The script to be run on onscroll

Technical Details

Supported HTML tags: <address>, <blockquote>, <body>, <caption>, <center>, <dd>, <dir>, <div>, <dl>, <dt>, <fieldset>, <form>, <h1> to <h6>, <html>, <li>, <menu>, <object>, <ol>, <p>, <pre>, <select>, <tbody>, <textarea>, <tfoot>, <thead>, <ul>

Related Pages

HTML DOM reference: onscroll event


❮ HTML Event Attributes