javascript 内部html 问题
我正在尝试获取节点的innerHTML 值。该值为D&O
。当我尝试使用innerHTML 获取此值时,我得到D &[分号] O。是否有任何选项可以获取确切的值而不是使用Javascript 的编码值?请帮我。
论坛阻止我在 & 之后输入分号
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 &
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
innerHTML
来返回提供您看到的文本的等效 HTML。You can use
innerHTML
will returns the equivalent HTML that would provide the text that you see.获取元素包含的文本节点中的数据。如果您需要文本而不是表示它的 HTML,请不要使用innerHTML。
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.