Active Accordeon Menu don't work with sublinks with query strings

一曲冷凌霜 提交于 2019-12-12 02:57:54

问题


@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:


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;


来源:https://stackoverflow.com/questions/16337875/active-accordeon-menu-dont-work-with-sublinks-with-query-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!