Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <style> #myDIV { height: 250px; width: 250px; overflow: auto; } #content { height: 800px; width: 2000px; background-color: coral; } </style> </head> <body> <p>Scroll inside the div element to display the number of pixels the content of div is scrolled horizontally and vertically.</p> <div id="myDIV" onscroll="myFunction()"> <div id="content">Scroll inside me!</div> </div> <p id="demo"></p> <script> function myFunction() { var elmnt = document.getElementById("myDIV"); var x = elmnt.scrollLeft; var y = elmnt.scrollTop; document.getElementById ("demo").innerHTML = "Horizontally: " + x + "px<br>Vertically: " + y + "px"; } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_scrollleft by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:29:00 GMT --> </html>
Result:
Try it Yourself - © w3schools.com