Last week I had a question on how to traverse the DOM and find all elements that had some text (p, a, li, h1, etc.) so I could manipulate it with Google's translation API. Well with some help from the community I was able to accomplish this feat.
http://groups.google.com/group/jquery-en/browse_thread/thread/c63da32785cc9be4/a357018b128506d9#a357018b128506d9 However, I have a bigger problem. Now, when I grab the all proper elements: $a = $(' #container > * ').contents(); And parse thru them to find which ones have text, it does just that BUT if an unordered list is within a div and that UL has text it will show up not only with the UL, but within the DIV as well. $a.each(function() { ... translate stuff here ..}); So in iteration one, we find the DIV, and then locate any and ALL text in the DIV. Quite a bit for the header navigation. Example Result for Div: HOME BUSINESS CONTACT ABOUT Then the next iteration is the UL, and it finds its text, which is basically the same as the DIV's text result. Example Result for UL: HOME BUSINESS CONTACT ABOUT Then the next iteration is the LI element, which has the proper text but, The next iteration is the A element which is finally the text I actually want to translate. Example Result for LI and A: HOME So my question is how can I traverse down and grab the last child on that particular "branch" of the DOM. Surely there's a way to check if current node has or does not have a child, but how with jQuery? Thanks! BTW, Ariel Fleisler's recommendation from the previous post appears to be the best approach, but my pure Javascript mixing with jQuery skills are not quite up to snuff to hash that out...