1
I’m making a menu where when I click on it I send a code to a page, this page it redirects to the page that was set with that id
. Up to this point it’s working only when I click on the submenu, it brings me his father’s code.
carregarPaginas();
function carregarPaginas() {
$(".subitem").click(function(e) {
e.preventDefault();
var acao = $(this).find('.acao').html();
location.href = 'includes/publicacao.php?c=' + acao;
});
$(".menuLi").click(function(e) {
e.preventDefault();
var acao = $(this).find('.acao').html();
location.href = 'includes/publicacao.php?c=' + acao;
});
};
Here comes the menu structure:
<li class="menuLi">
<div class="acao">-3</div>
<div class="desc">Servicos</div>
<div class="submenuC">
<ul class="submenu">
<li class="subitem">
<div class="acao">-4</div>
<div class="desc">Downloads</div>
</li>
<li class="subitem">
<div class="acao">-5</div>
<div class="desc">Videos</div>
</li>
</ul>
</div>
</li>
Forehead join
e.stopPropagation();
inside$(".subitem").click(function (e) {
– Sergio
Try what @Sergio commented, and also select
.acao
as the direct son of.menuLi
and.submenu
. You can dovar acao = $(' > .acao', this).html()
– Caio Felipe Pereira
vlw gave it right. makes an answer to min accept it.
– Renan Rodrigues
@Caiofelipepereira and So now the second li of the sub menu does not work.
– Renan Rodrigues
What is the "second li of the sub menu"? is in your example?
– Sergio
Now you see her
– Renan Rodrigues
Works well for me: http://jsfiddle.net/37p2crxs/
– Sergio
Thanks for helping.
– Renan Rodrigues
From the answer you’ve accepted tell me you don’t understand the problem....
– Sergio
The more it worked and the other was the only one who gave me a complete answer.
– Renan Rodrigues
Got some better solution @Sergio ?
– Renan Rodrigues
@Renanrodrigues my answer below. For example in jsFiddle I put here in the coments (http://jsfiddle.net/37p2crxs/).
– Sergio
Now it’s worked out, thanks again.
– Renan Rodrigues