1
I need to get content from a div. I’m actually building a dynamic menu, where I define
<li class="menuLi">
<div class="acao">-3</div>
<div class="desc">Inicio</div>
</li>
Then I have an ajax that should take this acao
and send to a page to know which page to load. However when caught this action is not coming, the attribute comes as undefined
.
The js code.
function carregarPaginas() {
$(".menuLi").click(function (e) {
e.preventDefault();
var acao = $(this).attr('href');
location.href = 'includes/publicacao.php?c='+acao;
});
}
$(this).attr('href')
would work if your LI was an A and had an attributehref
...– bfavaretto
how then ?
– Renan Rodrigues
Dude, strange this menu... <br> exchange: var acao = $(this). attr('href');<br> por: var acao = $(this). find('.acao'). html(); Ps.: $(".menuLi").click... needs to be right inside a function? Abs
– Marcelo Galvão
no, I need that when you click either the menu or the sub menu it pulls the page that comes with the code in action. would have to formulate a response ?
– Renan Rodrigues