Reputation: 185883
For a given Text node in the DOM, one can use one of these properties to retrieve its text:
textContent
data
nodeValue
wholeText
But which one to use? Which one is the most reliable and cross-browser supported?
(If multiple properties are 100% reliable and cross-browser, then which one would be most appropriate?)
Upvotes: 25
Views: 4938
Reputation: 816312
nodeValue
should be is cross-browser compatible. It is part of the original DOM Level 2 specification.
Also have a look at the compatibility table of quirksmode.org for that matter (that's what I always use to see which properties are supported by which browsers).
Upvotes: 11
Reputation: 20658
When you're 100% sure that it's a text node you can use any of them.
Upvotes: -1