I'm trying to get the innerHTML value of a node. The value is 开发者_如何转开发D&O
. When I try to get this value using innerHTML I'm getting D &[semicolon] O. Is there any option to get the exact value rather than encoded value using Javascript? Please help me.
Forum prevents me from entering semicolon after &
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.
element.firstChild.data;
Get the data in the text node contained in the element. If you want the text and not HTML that represents it, don't use innerHTML.
精彩评论