scrollLeft property is used to get the number of pixels that are scrolled from left.
If the elements direction is rtl (right-to-left), it returns 0.
var elem = element.scrollLeft;
Example - Getting the scrollLeft of an element
- In the above example, when the button is clicked fun_name() function is called.
- Using the scrollLeft property, when the content is scrolled to the left, it retrieves the total pixels of the scrolled area and displaying it (alert(attr.scrollLeft);).