Search code examples
kendo-uikendo-editor

How to get plain text from kendoEditor?


How to get only text from kendoEditor without style?

When I use $("#id").data("kendoEditor").value() it is returning value with style. But I want to get only text without the style.


Solution

  • Try the following snippet, which will just fetch Text within a DOM Element:

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

    Bind it with an HTML Button:

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