HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style> div{ border:1px solid black; line-height: 2; width: 120px; height:100px; overflow-y: scroll; } </style> </head> <body> <h1>jQuery scrollTop() Method</h1> <div> Here is some dummy text to make the div scrollable. Please don't forget to scroll up and down. </div> <p>scroll left is at = <span id="point">0</span>px</p> <script> $(document).ready(function(){ var count = 0; $("div").scroll(function(){ count += 1; $("#point").text($("div").scrollTop()); }); }); </script> </body> </html>
OUTPUT
×

Save as Private