【发布时间】:2017-04-12 02:16:06
【问题描述】:
我在 chrome 上收到错误“Uncaught RangeError: Maximum call stack size exceeded”。这是我的 jQuery 函数
$(window).scroll(function(){
if ($(this).scrollTop() < 170) {
$('#main-nav').css('position', '');
$('#fixed-header-icon').slideUp().addClass('remove');
if ($('.ajelnews').length > 0) {
$('.main-nav').removeClass('relative');
$('.main-nav').css('top', '');
}
if (!$('#main-nav').hasClass('main-nav')) {
$('#main-nav').removeClass("fixed-true");
$(".close-fixed-header").css('display', 'none');
}
}
});
从此行$(".close-fixed-header").css('display', 'none');
【问题讨论】:
-
试试
.css('display', 'none');,而不是.hide()。除此之外,我们真的可以使用MCVE。 -
我不希望 jQuery 的
css导致类似的事情(这是堆栈溢出错误)。正如 Cerbrus 所说,我们需要一个minimal reproducible example。 -
scroll事件多次触发......我的猜测是.slideUp()是实际原因
标签: javascript jquery google-chrome