我有一个可在Chrome中运行的JavaScript代码,但它拒绝在Mozilla Firefox中运行。为什么会这样?
HTML
<div class="scroll-arrows">CLICK TO SCROLL</div>
CSS
body{
height: 2000vh;
}
JS
$(document).on('click', '.scroll-arrows', function() {
return $('body').animate({
scrollTop: 400
}, 'slow');
});
答案 0 :(得分:1)
正如Animate scrollTop not working in firefox
中已提到的那样您必须使用$('body,html').animate( {scrollTop: 400}, 'slow');