I'm trying to get the contents of a DOM node, which contains the text “D&O”. When I try to get this value using innerHTML
I'm getting "D&O"
. Is there any option to get the raw value rather than the encoded value using JavaScript?
You can use
return ("innerText" in node) ? node.innerText : node.textContent;
innerHTML
will returns the equivalent HTML that would provide the text that you see.