jQuery scrollLeft() set horizontal position

Introduction

Set horizontal 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>/*from  w ww  . j a v a  2  s .c  o  m*/
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("div").scrollLeft(100);
  });
});
</script>
</head>
<body>

<div style="border:1px solid black;width:100px;height:130px;overflow:auto">
ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
</div><br>

<button>Set</button>

</body>
</html>



PreviousNext

Related