问题描述
我在使用HTML实体作为引号的元素中包含文本内容。我需要获取此内容并将其插入到另一个元素的data属性中,这当然要求引号保持转义。但是无论我做什么,JS都会不断将实体转换为字符。我该如何预防?
let lmnt = document.getElementById('lmnt');
console.log(lmnt.textContent);
console.log(lmnt.innerHTML);
console.log(lmnt.innerText);
<html>
<body>
<h1 id="lmnt">Robert "Bob" Robertson</h1>
</body>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)