Reputation: 113
My JQuery .animate() function seems to not working on IE. Could You please help me transform it to a pure JS solution?
var brandLink = $('#brand');
var pageTop = $('#page-top');
var navLinks = $('.nav-link');
var offerSection = $('#offer');
var techSection = $('#tech');
var portfolioSection = $('#portfolio');
var contactSection = $('#contact');
var moreBtn = $('.more-button');
navLinks.eq(0).click(() => {
$('html, body').animate({
scrollTop: pageTop.offset().top
}, 500);
});
As You can see this is used for scrolling page to propper section/page-top in One page website.
Can someone explain why animate() doesn't work on IE?
Upvotes: 1
Views: 171
Reputation: 859
Depending on the version of IE you need to support, have a look at this site. You will find some generic turnarounds that might help.
Also have a look at this (adding a preventDefault(); to make sure the script is working properly).
Upvotes: 0
Reputation: 3641
Quick shot, try:
var brandLink = $('#brand');
var pageTop = $('#page-top');
var navLinks = $('.nav-link');
var offerSection = $('#offer');
var techSection = $('#tech');
var portfolioSection = $('#portfolio');
var contactSection = $('#contact');
var moreBtn = $('.more-button');
navLinks.eq(0).click(function(e) {
e.preventDefault(); // to prevent native behaviour of the thing you press
$('html, body').animate({
scrollTop: pageTop.offset().top
}, 500);
});
Upvotes: 1