jQuery scrollTop() not working in IE11

淺唱寂寞╮ 提交于 2019-12-10 20:56:23

问题


I have some code that simply activates by clicking a button. When clicked, you are scrolled to that ID, that section of the site/page. It works everywhere except in IE11(the only version of IE I have). What is wrong?

jQuery(document).ready(function(){
jQuery('#seemore').click(function(){
    jQuery('body').animate({
        scrollTop: jQuery('#pgc-2040-0-1').offset().top + 40
    }, 800);
});
jQuery('#order, .order').click(function(){
    jQuery('body').animate({
        scrollTop: jQuery('#panel-2040-3-0-0').offset().top + 40
    }, 800);
}); 
}); 

Thank you!

The site is here: http://jobbcv.se It is the two red buttons at start I'm talking about.


回答1:


Change it to include html:

$('html, body').animate({
    scrollTop: $('#pgc-2040-0-1').offset().top + 40
}, 800);

And helpful hint, you can replace jQuery with $



来源:https://stackoverflow.com/questions/29153607/jquery-scrolltop-not-working-in-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!