HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> #outerDiv{ height: 200px; width: 300px; border:1px solid black; overflow: auto; } #innerDiv{ margin-top:750px; height: 2000px; width: 1000px; background:#d9d9d9; } </style> </head> <body> <div id="outerDiv"> <div id="innerDiv"> content inside innerDiv. </div> </div> <p>Click on the button to the top of the innerDiv</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementById("innerDiv"); function myFunction() { elem.scrollIntoView(); } </script> </body> </html>
OUTPUT
×

Save as Private