0

I have a javascript code that works in Chrome but it refuses to work in Mozilla Firefox. Why is that so?

My 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');
});
Alex Nikolsky
  • 2,087
  • 6
  • 21
  • 36
  • 2
    The problem is not with handling the "click" event; that works fine, as a quick introduction of a `console.log()` call would show you. – Pointy Dec 06 '15 at 15:28
  • 4
    To handle FF, use `$('html, body').animate({...});`. FYI, your `return` statement has no meaning here – A. Wolff Dec 06 '15 at 15:29

1 Answers1

1

As already mentioned in Animate scrollTop not working in firefox

You have to use $('body,html').animate( {scrollTop: 400}, 'slow');

Community
  • 1
  • 1
CHF
  • 264
  • 4
  • 17