Javascript Jquery不在IE中工作无法获取属性';顶部';指未定义的或空的引用
我正在使用Jquery-1.7,下面是我的Jquery代码。 它在chrome中工作,但在IE中失败Javascript Jquery不在IE中工作无法获取属性';顶部';指未定义的或空的引用,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,我正在使用Jquery-1.7,下面是我的Jquery代码。 它在chrome中工作,但在IE中失败 $(window).bind('scroll', function () { if ($(this).attr('scrollY') > $('#footerCenter').offset().top - $(window).height() - 60) { if ($('#earthMoonLink').hasClass('more')) {
$(window).bind('scroll', function () {
if ($(this).attr('scrollY') > $('#footerCenter').offset().top - $(window).height() - 60) {
if ($('#earthMoonLink').hasClass('more')) {
$('#earthMoonLink').removeClass('more').text('earth').attr({href: '#Earth', title: 'Back to Top'});
}
} else {
if (!$('#earthMoonLink').hasClass('more')) {
$('#earthMoonLink').addClass('more').text('moon').attr({href: '#Moon', title: 'Jump to Footer'});
}
}
});
我在IE9和IE10上的错误率都在下面
SCRIPT438: Object doesn't support property or method 'getElementsByTagName'
jquery.min.js, line 16 character 59008
SCRIPT5007: Unable to get property 'top' of undefined or null reference
base.js, line 48 character 9
我很肯定
$(this).attr('scrollY')
应该是
this.scrollY
据我所知,这是一个有效的属性错误意味着选择器
#footerCenter
不正确,并且没有返回任何可见元素。你能发布HTML来配合这个吗?(或者更好的是一个JSFIDLE)您希望代码中的this
是什么:$(窗口).bind('scroll'),…$(this.attr('scrollY')
?@HiTechMagic:上面的代码在chrome中工作。@Sergio:我正在尝试移动鼠标滚动页面的内容。jsFIDLE任何特定的内容