当字符串包含html实体时,在Javascript中设置文本节点的nodeValue [英] Setting nodeValue of text node in Javascript when string contains html entities
本文介绍了当字符串包含html实体时,在Javascript中设置文本节点的nodeValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用
node.nodeValue="string with &#xxxx; sort of characters"
&符号被转义。有一个简单的方法吗?
ampersand gets escaped. Is there an easy way to do this?
推荐答案
您需要使用Javascript转义为Unicode字符:
You need to use Javascript escapes for the Unicode characters:
node.nodeValue="string with \uxxxx sort of characters"
这篇关于当字符串包含html实体时,在Javascript中设置文本节点的nodeValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文