I’m building a page which has to scroll with animation to certain positions when something happens.
I’m applying jQuery.animate to document.documentElement and it seems to work properly on Firefox and some versions of IE, while on Chrome and other versions of IE it has to apply to document.body to work.
Am I being an idiot here? What am I missing? And if I’m not, what is the proper way to detect which one to use?
You’re not an idiot, it has always been tricky, see comments here for example 🙂
As far as I remember,
$('html, body').animate({scrollTop: '-=100'})works in all major browsers now.