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!
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.