i have this:
<div id="parent" style="overflow:auto">
...
<div id="test">Hello</div>
...
</div>
My question is: how to scroll parent div to have test div as first line of parent ?
If you don't want to use a plugin, see element.scrollIntoView
:
$("#test").get(0).scrollIntoView();
// Plain ol' JS:
document.getElementById("test").scrollIntoView();
http://plugins.jquery.com/project/ScrollTo
The easiest way is to use this plugin.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.