ScrollTop - Animate Function does not work in IE
I've got this function (throws an error):
- $(function () {
- function scrollToAnchor(aid) {
- var aTag = $("a[name='" + aid + "']");
- $('html,body').animate({ scrollTop: aTag.offset().top }, 100);
- }
I get this error:
JavaScript runtime error: Unable to get property 'top' of undefined or null reference
It seems to work in Chrome, though most of our users are directed to using IE. (errors in v9-11)