How to insert HTML entities with createTextNode?

后端 未结 3 493
执念已碎
执念已碎 2020-12-06 01:52

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 =          


        
3条回答
  •  时光说笑
    2020-12-06 02:36

    You can't create nodes with HTML entities. Your alternatives would be to use unicode values

    var dropdownTriggerText = document.createTextNode('blabla \u0026');
    

    or set innerHTML of the element. You can of course directly input &...

提交回复
热议问题