Say I have a html element like the following:
<p id="targetElement">There is a long sentence here.
The sentence is so long that it overflows from the element.</p>
With css like:
#targetElement{
width:50px;
height:50px;
overflow-y:auto;
}
Now, the sentence inside the #targetElement tag is not going to fit(hopefully, it's long enough, but even if it's not, I hope you get the idea), so there is going to be a scroll bar on #targetElement.
With that all been said, here is what I want. I want a javascript function that gives me the scroll amount (scrollTop() amount in jQuery) when I input the nth character I want to scroll to.
It would be something like this:
function scrollToChar(charIndex){
//some how get scrollTop() to nth character like this
var scroll=$("#targetElement").nth-char(charIndex).scrollTop();
return scroll;
}