Reputation: 57891
I want to know how much is the <textarea>
or <div style="overflow:scroll">
scrolled. Vertically or horizontally. I expect an answer like this:
function getElementVerticalScroll(el){
return integer
}
Upvotes: 1
Views: 116
Reputation: 154858
If you don't want to bring in a library, have a look at the scrollTop
property of the element: http://jsfiddle.net/pimvdb/GXGHB/2/.
textarea.scrollTop;
Upvotes: 1
Reputation: 349042
I've filled in the blank space of your function:
function getElementVerticalScroll(el){
return el.scrollTop;
}
function getElementHorizontalScroll(el){
return el.scrollLeft;
}
Upvotes: 1
Reputation: 14863
Using jQuery, I think $(element).scrollTop();
should do the vertically-lookup. And scrollLeft
for horizontal.
Upvotes: 0