I have this HTML from Drupal
<span id="terms" style="visibility:hidden">
<ul class="links inline">
<li class="taxonomy_term_14 first"><a href="/taxonomy/term/14" rel="tag" title="National Site">national</a></li>
<li class="taxonomy_term_2 last"><a href="/category/region/all/nyc" rel="tag" title="">nyc</a></li>
</ul></span>
I am using this JQuery to get the text “nyc” from the second <li>.
var tagText = $("#terms li + li").text();
when I check to view tagText, document.write(tagtext) shows “nynynynynynynynynynynynynynynyny” instead of just “nyc.” Why is it repeating?
or
or
I believe both should work.
OR if you want to get fancy you cold use the
:nth-child(n)selector (not 0 based)Based on your question however…
$("#terms li:last").text()should do the trick.