所以我有一个跨度
<span class="delete-btn">✘</span>
并且正在尝试包含 x - ✘
的 HTML unicode在文本节点内 -
span.appendChild(document.createTextNode("✘"));
但是这根本行不通。有什么想法吗?
最佳答案
您可以简单地使用\u2718
:
let span = document.getElementsByClassName('delete-btn')[0];
span.appendChild(document.createTextNode('\u2718'));
<span class="delete-btn">✘</span>
关于javascript - 如何将 html unicode 添加到 createTextNode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49944503/