【问题标题】:contenteditable shows markup at the resultcontenteditable 在结果中显示标记
【发布时间】:2015-06-16 18:52:27
【问题描述】:

我使用contenteditable 作为文本输入,我想在用户点击“提交”时显示(在不同的 div 上)文本输入。

假设用户类型:

hello
hello

我检查一下

$('.answer_comments_editable').html();

然后我得到"hello<div>hello</div>"

我不想在最终显示中显示任何 html 标记,那么如何避免这种情况,而是显示干净的文本?

【问题讨论】:

    标签: html contenteditable


    【解决方案1】:

    试试textContent 属性

    var contenteditable = document.querySelector('.answer_comments_editable'),
        text = contenteditable.textContent;
    

    【讨论】:

    • 我将 $('.answer_cmets_editable').html() 更改为 $('.answer_cmets_editable').textl() 及其工作。谢谢
    • 不要从上面的评论中复制粘贴?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 2014-11-11
    • 2015-01-18
    • 2021-09-18
    • 1970-01-01
    相关资源
    最近更新 更多