Javascript examples for DOM Event:onscroll
The onscroll event occurs when an element's scrollbar is being scrolled.
Bubbles | No |
---|---|
Cancelable | No |
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> |
<!DOCTYPE html> <html> <head> <style> div {//from www .ja va 2s .c o m border: 1px solid black; width: 200px; height: 100px; overflow: scroll; } </style> </head> <body> <div onscroll="myFunction()"> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <br><br> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <br><br> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <br><br> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <br><br> </div> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "You scrolled in div."; } </script> </body> </html>