Active Accordeon Menu don't work with sublinks

2019-08-30 08:10发布

@Ejay Help me to set "opened" the main link if i click iin some sublinks of this...

here: Set "active" accordion menu after click

i make some modifications like:

<script type="text/javascript">
        $(document).ready(function(){

            var sPath = window.location.pathname;
            var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

            var url = sPage.split('?')[0];

            $('dd').filter(function () {
               return $('a[href="' + url + '"]', $(this)).length == 0
            }).hide();

            $('dt a.submenu').click(function () {
               $("dd:visible").slideUp("slow");
               $(this).parent().next('dd').slideDown("slow");
               return false;
            });

        });
</script>

This script only works if my link is

<a href="test.asp">TESTE</a>

if my link is that way: <a href="test.asp?category=BLABLABLA">BLABLABLA</a> this don't work..

what is wrong

Can see the menu working partly here: http://alsite.com.br/saks_div/

1条回答
The star\"
2楼-- · 2019-08-30 08:13

if

var sPath = window.location.pathname;  

works for URL's like abc.asp then following should work with URL's having a query string, e.g., produtos_categoria.asp?categoria=something

var sPath = window.location.pathname+window.location.search;
查看更多
登录 后发表回答