jQuery scrollTop()在IE11中不起作用 [英] jQuery scrollTop() not working in IE11

查看:444
本文介绍了jQuery scrollTop()在IE11中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些只需单击一个按钮即可激活的代码.单击后,将滚动到该ID,即网站/页面的该部分.除IE11(我拥有的IE的唯一版本)外,它均可在任何地方使用.怎么了?

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);
}); 
}); 

谢谢!

该站点在此处: http://jobbcv.se 我正在谈论的是开始时的两个红色按钮.

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

推荐答案

将其更改为包含html:

Change it to include html:

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

有用的提示,您可以将jQuery替换为$

And helpful hint, you can replace jQuery with $

这篇关于jQuery scrollTop()在IE11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆