1
I have the following menu structure:
<ul id="responsiveAccordion" class="showedmenu">
<li><a title="Página Inicial" href="/">Página Inicial</a></li>
<li id="category_item_1">
<div class="responsiveInykator"><span>Teste </span><i class="fa fa-angle-down fa-2" aria-hidden="true"></i></div>
<a href="/">Início</a>
<ul style="display: block;">
<li><a title="Categoria 1" href="/categoria-1">Categoria 1</a></li>
<li><a title="Categoria 2" href="/categoria-1">Categoria 2</a></li>
</ul>
</div>
</li>
</ul>
...
In my code, when I do console below:
console.log($('#responsiveAccordion > li .responsiveInykator').parent().children()[1]);
He shows me:
<a href="/">Início</a>
I would like to capture the text of the link: "Start"
I tried that but it was wrong:
console.log($('#responsiveAccordion > li .responsiveInykator')
.parent()
.children()[1].text());
Okay, make a mistake, thank you!
– Ivan Ferrer
You’re welcome @Ivanferrer
– Miguel
Miguel (and @Ivanferrer) , it is worth mentioning that
.text
only works on a few elements. Is part of HTML API and it would be better to use the.textContent
or the.innerHTML
.– Sergio
Edited @Sergio. Obgado by tip
– Miguel