Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Get Text of a element Re: Get Text of a element

#102156
Mottie
Member

Try this instead… it’s more direct (demo)

this.parentNode.parentNode.getElementsByTagName('span')[0].title

The problem with the code above is that the first child node isn’t the span, it’s a text node from the tab to format the HTML. So changing that to

this.parentNode.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.childNodes[1].title

would also work, but it’s much more rigid in that if you change the number of table cells it will break.