简体   繁体   中英

javascript: scroll a div to the bottom

I have code like

function scrollme(){
dh=document.body.scrollHeight
ch=document.body.clientHeight
if(dh>ch){
moveme=dh-ch
window.scrollTo(0,moveme)
}
}

But I want it to only scroll a div named "feed" not the whole page. How can I do this?

document.getElementById('feed').scrollTop = y;

https://developer.mozilla.org/en/DOM/element.scrollTop

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM