开发者

javascript innerhtml issue

开发者 https://www.devze.com 2023-01-01 17:25 出处:网络
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 &amp[semicolon] O. Is there any option to get t

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 &amp[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 &amp


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号