Scroll the scroll bar - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:scrollLeft

Description

Scroll the scroll bar

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").scrollLeft(100);
    });/*from w w  w .  j  a  v  a2 s  . co  m*/
});
</script>
</head>
<body>

<div style="border:1px solid black;width:100px;height:130px;overflow:auto">
This is a test. This is a test. This is a test.This is a test. This is a test. This is a test.This is a test. This is a test. This is a test.
</div><br>

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

</body>
</html>

Related Tutorials