简体   繁体   中英

Navigation not working on IE8

I have the following jQuery code:

$(function() {
    $('ul.step-navigation li a').bind('click',function(event){
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500,'easeInOutExpo');
        event.preventDefault();
    });
});

It is used to navigate to different sections on the page via the top navigation. It works 100% with FireFox, Chrome, IE9+, but not on IE8.

Some answers here suggest to remove the easing, for example this one: Trouble implementing Smooth Vertical scrolling with jQuery but it does not work in my case.

Please assist if you can see why this does not work in IE8? It simply ignores the click event.

After a lot of research, I found this: background is not support in ie8 only? after struggling with ANOTHER issue regarding backgrounds in IE8 when using <section> tags, and when I included modernizr, it also solved the navigation issue.

I understand that the HTML5 elements such as the <section> element is not supported in IE8, and that is why the background now works, but I am not sure yet why it solved the navigation problem.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM