Hello,

Just a post to share the code, because I spend some times to
automatically add the class current to all <li>'s parent tags when you
click on the superfish navbar menu...

so here the jquery code:
<script type="text/javascript">

            $(document).ready(function(){
                $("ul.sf-menu").superfish({
                    pathClass:  'current'
                });

                $('#menu2 li a').click(function() {
                    $("#menu2 li").removeClass('current');
                    $(this).parents().filter("li").addClass
('current');
                    $("ul.sf-menu").superfish({
                        pathClass:  'current'
                    });
                });
            });

        </script>

And the html, is a usual for menus...

<div id="menu2">
        <ul class="sf-menu sf-navbar">
            <li>
                <a href="#" >Admin</a>
                <ul>
...

I start learning jquery with this problem, and even if it works, I
think there is a better way to set the class current to all the
parents BUT just for the <li>'s parents...

The idea was to set a function on the link $(this) and then use the
parents function and select only the li...
$(this).parents().filter("li").addClass('current');

Does filter is the good way ?


thanks;

arnaud


Reply via email to