Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textarea: select text and scroll to it with javascript

I've been trying to find this solution for the past few hours, but no luck so far. How could i select some text (actually found that one already, but haven't tested completely yet) in a textarea and force it to scroll to that text? I've tried using scrollTop, but i don't really know how to calculate it properly with the number of lines of the wrapping textarea in mind.

like image 268
Marius Avatar asked May 06 '26 10:05

Marius


1 Answers

Think this would be good for what you're trying to do:

http://flesler.blogspot.com/2007/10/jqueryscrollto.html

Can use it to scroll DOM elements, in this case the text you're selecting.

like image 115
timothyclifford Avatar answered May 09 '26 14:05

timothyclifford



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!