问题
@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