onscroll Event

Event Object Reference Event Object

Example

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

<div onscroll="myFunction()">

Try it yourself »


Definition and Usage

The onscroll event occurs 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
onscroll Yes Yes Yes Yes Yes


Syntax

In HTML:

<element onscroll="myScript">Try it

In JavaScript:

object.onscroll=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

object.addEventListener("scroll", myScript);Try it

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

Bubbles: No
Cancelable: No
Event type: UIEvent
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>
DOM Version: Level 2 Events


Event Object Reference Event Object

Color Picker

colorpicker