如何使用createTextNode插入HTML实体? [英] How to insert HTML entities with createTextNode?
本文介绍了如何使用createTextNode插入HTML实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我想将ascii符号格式js添加到某个节点?
尝试作为 TextNode
,但它没有将其解析为代码:
If I want to add an ascii symbol form js to a node somewhere?
Tried as a TextNode
, but it didn't parse it as a code:
var dropdownTriggerText = document.createTextNode('blabla ∧');
推荐答案
您无法使用HTML实体创建节点。您的替代方案是使用unicode值
You can't create nodes with HTML entities. Your alternatives would be to use unicode values
var dropdownTriggerText = document.createTextNode('blabla \u0026');
或设置 innerHTML
元素。您当然可以直接输入&
...
or set innerHTML
of the element. You can of course directly input &
...
这篇关于如何使用createTextNode插入HTML实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文