- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Get Text of a element
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.
Thank you Mottie!
I did have to change the 0 to a 1 to get it to work, not sure why.
this.parentNode.parentNode.getElementsByTagName('span')[1].title
I didn’t see your full HTML, but most likely there is more than one span in that table row.
Not sure why but it doesnt like IE, I’ve tried it on firefox and chrome and it works great.
Any ideas on why IE doesnt work?