How To Prevent Textarea From Scrolling To The Top When Its Value Changed?
Consider the following example: (Live demo here) HTML:
CSS: textarea { height: 80px; width:Solution 1:
You can save the scrollTop offset, set the value, and reset the scrollTop to the old offset:
var$textarea = ...;
var top = $textarea.scrollTop();
$textarea.val('foo');
$textarea.scrollTop(top);
Try it here: http://jsfiddle.net/QGJeE/7/
Post a Comment for "How To Prevent Textarea From Scrolling To The Top When Its Value Changed?"