विश्व का सबसे बड़ा हिंदी वेब डेवलपर साइट

HTML onscroll Event Attribute

HTML Event Attributes HTML Event Attributes


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

Differences Between HTML 4.01 and HTML5

The onscroll attribute is new in HTML5.


<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 HTML Event Attributes