Scroll to top - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:scrollTop

Description

Scroll to top

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("div").scrollTop(100);
    });//from   w w w.  j av  a2s. c o  m
});
</script>
</head>
<body>

<div style="border:1px solid black;width:100px;height:150px;overflow:auto">
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</div><br>

<button>Set vertical scrollbar position to 100px</button>

</body>
</html>

Related Tutorials