亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - The difference between html and body in jquery selector
怪我咯
怪我咯 2017-05-19 10:43:53
0
2
858
//第一種是正常的點(diǎn)擊返回頂部
// 滾動(dòng)條
$('#back_to_top').click(function(){
    // $(window).scrollTop(0);
})

//第二種是加了滾動(dòng)條變化的動(dòng)畫(huà)效果
// 滾動(dòng)條
$('#back_to_top').click(function(){
    $('html,body').stop().animate({
        scrollTop:"0px"
    },"slow")
})

The first time is $(window) and the second time is $('html,body')
What are the differences between these three? When to use window, when to use html, and when to use body?
Also why sometimes both html and body are written in.

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(2)
習(xí)慣沉默

$('html,body') Why do you need to write 2? It's because firefox ie does not support body, but chrome supports body, so I write it like this for compatibility. You can try firefox and chrome to understand.

迷茫

For forms and DOM objects, obtaining relevant properties is also related to the document model. As for the scrollTop you mentioned, the xhtml mode body is 0, html is the scroll height, and the backcompat mode returns
window's scrollTop returns the scroll height pageYOffse

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template