jQuery scrollTop() Set vertical scrollbar position to 100px

Description

jQuery scrollTop() Set vertical scrollbar position to 100px

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*  www .j a v a2 s .  c o  m*/
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("div").scrollTop(100);
  });
});
</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>test</button>

</body>
</html>



PreviousNext

Related