I'm trying to set accordion menu "active" after click on link and change the page...
<div class="menu">
<dl>
<dt><a href="index.asp">HOME</a></dt>
<dt><a href="#" class="submenu">QUEM SOMOS</a></dt>
<dd>
<ul>
<li><a href="empresa.asp">EMPRESA</a></li>
<li><a href="institucional.asp">INSTITUCIONAL</a></li>
<li><a href="nossos_produtos.asp">NOSSOS PRODUTOS</a></li>
<li><a href="responsabilidade_social.asp">RESPONSABILIDADE SOCIAL</a></li>
<li><a href="responsabilidade_ambiental.asp">RESPONSABILIDADE AMBIENTAL</a></li>
</ul>
</dd>
<dt><a href="#" class="submenu">PRODUTOS</a></dt>
<dd>
<ul class="produtos">
<%do while not rscat.EOF%>
<li><a href="produtos_categoria.asp?categoria=<%= rscat("categoria")%>"><%= rscat("categoria")%></a></li>
<% rscat.MoveNext
if rscat.EOF then Exit do %>
<% Loop %>
</ul>
</dd>
<dt><a href="informativo.asp">INFORMATIVO</a></dt>
<dt class="no_border"><a href="contato.asp">CONTATO</a></dt>
</dl>
</div>
jquery:
<script type="text/javascript">
$(document).ready(function(){
$('dd').hide();
$('dt a.submenu').click(function(){
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
return false;
});
});
</script>
i'm trying too, use this https://stackoverflow.com/questions/10681033/accordion-menu-active-state-after-link-click but dont work...
what i try (but don't work):
<script type="text/javascript">
$(document).ready(function(){
$('dd').hide();
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
$("dt a.submenu[href='" + sPage + "']").parents("dd:visible").show();
$('dt a.submenu').click(function(){
$("dd:visible").slideUp("slow");
var checkElement = $(this).next();
if ((checkElement.is("dd")) && (checkElement.is(":visible"))) {
return false;
}
if ((checkElement.is("dd")) && (!checkElement.is(':visible'))) {
$(this).parent().next().slideDown("slow");
checkElement.slideDown("normal");
return false;
}
});
});
</script>
Well, the first sublinks ul
point to especific pages, but the another sublink ul class=produtos
show the categories that's on database, and uses same link on each categories like: produtos_categoria.asp?categoria=xxxxxx
...
If the user, click on "EMPRESA", on the page empresa.asp
the QUEM SOMOS
menu need to be opened. And if the user click on some categories under the menu PRODUTOS
, on the page produtos_caegoria.asp
the PRODUTOS
need to be opened..
I'm clear?
So.. what i need to do?
FIDDLE: http://jsfiddle.net/Qf7Js/1/