This code:
jQuery('body').animate({scrollTop: target.offset().top}, 300);
Works in firefox, but not chrome.
This code:
jQuery('html').animate({scrollTop: target.offset().top}, 300);
Works in chrome, but not firefox.
I haven't tested yet in IE.
What is the correct way to do this, cross-browser? If it's not clear from the above snippets, I target is a div on the page, and I want to scroll down slowly to it slowly, so they do exactly what I want... just not cross-browser.
同时指定html
和body
:
$("html,body").animate({scrollTop: target.offset().top}, 300);
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.