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?)
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?)
Share Improve this question edited Sep 1, 2019 at 0:53 user719662 asked Oct 7, 2011 at 17:17 Šime VidasŠime Vidas 186k65 gold badges287 silver badges391 bronze badges 02 Answers
Reset to default 11nodeValue
should be is cross-browser patible. It is part of the original DOM Level 2 specification.
Also have a look at the patibility table of quirksmode for that matter (that's what I always use to see which properties are supported by which browsers).
When you're 100% sure that it's a text node you can use any of them.