【问题标题】:How to get plain text from kendoEditor?如何从 kendoEditor 获取纯文本?
【发布时间】:2017-04-07 09:40:06
【问题描述】:

如何只从 kendoEditor 获取没有样式的文本?

当我使用$("#id").data("kendoEditor").value() 时,它会返回带有样式的值。但我只想获取没有样式的文本。

【问题讨论】:

    标签: kendo-ui kendo-editor


    【解决方案1】:

    试试下面的 sn-p,它只会在 DOM 元素中获取文本:

    function getClick(e) {
        try {
            var text = $('#editor').getKendoEditor().value()
            var strippedText = text.replace(/(<([^>]+)>)/ig,"");
            alert(strippedText);
        }
        catch (e) { }
    }
    

    用 HTML Button 绑定它:

    <button class="k-button" id="btnPreviewContent" onclick="getClick()">PreviewEditor Content</button>
    

    【讨论】:

    • 没有。我越来越喜欢“我的文本”。但我只想要“我的文字”。
    • 检查包含剥离正则表达式的更新帖子
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-14
    • 2021-02-26
    • 2015-08-26
    • 1970-01-01
    相关资源
    最近更新 更多