There are many ways to retrieve/change the value of a text node:
- It's not
textnode.value
, a XUL-only thing textContent
[mdn] is not supported until IE9data
, inherited byText
from theCharacterData
interfacenodeValue
[mdn] from theNode
interface
I tend to use .data
. Which of them is recommended - they all return the same?
If you have a TEXT_NODE [type 3] textContent will return the nodeValue (MDN):
CharacterData is the same as nodeValue for text nodes (MDN).
For text nodes they are the same.
jQuery (Sizzle) uses nodeValue:
So using data is fine, but textContent is IE9+ only and a bit slower.