1

Long story short, I need to get the total scroll size for a text area, in a unit scrollTop can relate to, but I have no idea how.

scrollHeight, this, that and everything else seemed to be no help. Any suggestions would be appreciated, but for reference, it needs to be able to set a text area of variable size and length's scroll bar to be exactly in the middle.

Also, I'm using chrome 12 if that matters.

2 Answers 2

1

this may help you :

element.scrollTop = element.scrollHeight - (element.clientHeight / 2);
Sign up to request clarification or add additional context in comments.

Comments

0

This works for me:

$('#foo').scrollTop($('#foo')[0].scrollHeight / 2);

And a demo thing: http://jsfiddle.net/Rgyk4/8/.

1 Comment

That only seems to work based on the relative location on the page. At least it doesn't work for me for that which I am doing. (unless Jquery is compensating for something)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.