JavaScript element.scrollLeft Property
You are Here:
JavaScript element.scrollLeft Property
The element.scrollLeft
property gets or sets the number of pixels an element's content is scrolled horizontally.
Note: If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position, and then increasingly negative as you scroll towards the end of the content.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<div id="outerDiv" onscroll="myFunction()">
<div id="innerDiv">Scroll me down and top</div>
</div>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var elem = document.getElementById("outerDiv");
function myFunction(){
x.innerHTML = "scrollTop = " +elem.scrollTop;
}
</script>
</body>
</html>
Syntax
element.scrollLeft
Return Values
Value | Explanation |
---|---|
Number | Returns the number of pixels an element's content is scrolled horizontally. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.