Why doesn't it work with regard to selecting navigation highlights?

<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    <script type="text/javascript">
$(document).ready(function(){         
    $("-sharpnav > li").find("a").click(function(){
        $("-sharpnav").find("li").removeClass("active");
        $(this).parent("li").addClass("active");
    });
});
    </script>
                                                                        <div class="z-nav-container" >
<ul class="z-nav-conter menu clearfix" id="nav">
            <li ><a href="/"  ><span></span></a></li>
            
         <li><a href="/a1brand/"><span></span></a></li>
     <li><a href="/product/" ><span></span></a>
    <ul class="z-nav-sub">
        <li><a href="/product/meishidapei/"><span></span></a></li>
        
        <li><a href="/product/nut/"><span></span></a></li>
        
        <li><a href="/product/seaSedge/"><span></span></a></li>
        
        <li><a href="/product/negative/"><span></span></a></li>
        
        <li><a href="/product/donkeyHideGelatinCake/"><span></span></a></li>

    </ul>
    </li>
        <li><a href="/foundingTeam/"><span></span></a></li>
        <li><a href="/a/news/" ><span></span></a></li>
        <li><a href="/contact/" ><span></span></a></li>
</ul>

                                                                        </div>

Why can"t class= "active" highlight be added when navigation is selected using the above code? solve

Mar.04,2021

you click on a link, highlight, and then jump to another page


if you try to remove all the contents of your href, you will find that it is because of your jump that the highlight style disappears.
if you want to jump to retain the style, I know there are two ways
1. You can save this location with cache / link parameters, and determine the location of active on the new page according to the parameters / cache on the link when you jump.
2. Take nav as the public part and get the new page through document.

Menu