为什么onclick事件在Firefox中不起作用?

时间:2015-12-06 15:25:43

标签: javascript jquery html firefox

我有一个可在Chrome中运行的JavaScript代码,但它拒绝在Mozilla Firefox中运行。为什么会这样?

我的Codepen sandbox

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

1 个答案:

答案 0 :(得分:1)

正如Animate scrollTop not working in firefox

中已提到的那样

您必须使用$('body,html').animate( {scrollTop: 400}, 'slow');