JQuery not working in Internet Explorer 8

addclass, internet-explorer, jquery

Solution

To make HTML5 elements work with non html5 compliant browsers you need to include htmlshiv http://code.google.com/p/html5shiv/

also as indicated in other answers it should be `nav` instead of `navi` http://www.w3.org/WAI/GL/wiki/Using_HTML5_nav_element

add the following in the script section

<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

and modify the selector like

$(document).ready(function() {
    $('nav a[href^="' + location.pathname.split("/")[1] + '"]').closest('li').addClass('select');
});

here is a blog post(courtesy @Ravi) by John Resig you may find useful http://ejohn.org/blog/html5-shiv/

Problem

I have html as below: ``` <navi> <ul class="fnt_menu_secondo_livello" id="menu_secondo_livello"> <li><a href="Retailers.aspx" title="Account Set up">Account Set Up</a></li> <li><a href="RetailerLogin.aspx" title="Retailer Login">Retailers Login</a></li> <li><a href="ManufacturerLogin.aspx" title="Manufacture Login">Manufacturers Login</a></li> <li><a href="PriceListRequest.aspx" title="Price List Request">Price List Request</a></li> <li><a href="Education.aspx" title="Price List Request">Education</a></li> </ul> </navi> ``` And I'm using this code to addClass to the current menu: ``` $(document).ready(function() { $('navi a[href^="' + location.pathname.split("/")[1] + '"]').closest('li').addClass('select'); }); ``` This is working fine in other browsers except IE8. Let me know what is wrong with this.?

Original source