0

I have javascript in a Rails project that only runs in Chrome. I've tested it in Firefox and IE and I get nothing. Am I overlooking something simple?

<script>
$(function() {
    $("#edit").on("click", function() {
    $("body").animate({"scrollTop": window.scrollY+130}, 1000);
    return false;
}),
$("#edit-on-two").on("click", function() {
    $("body").animate({"scrollTop": window.scrollY+130}, 1000);
    return false;
});
})
</script>

Thank you in advance for the help!

1 Answers1

0

I would add "html" as an element in the animate() call, like this:

$("html, body").animate({"scrollTop": window.scrollY+130}, 1000);

There are issues with Webkit/Firefox and whether they can animate "html" or "body".

See this answer for more information on html vs. body

Community
  • 1
  • 1
rgutierrez1014
  • 396
  • 4
  • 9