Search code examples
htmljquerykendo-ui

How to change from Decode Html to text normal


I have change value in textarea to Decode. I want change from value Decode Html to text normal. How I do it?

        $("#editor").kendoTextArea({
            change: function (e) {
                var value = this.value();
                var decoded = $("textarea").html(value).text();
                $("#9").text(decoded);
            }
        });

result example: < strong >sadsadasdas< /strong >. I want: < strong >sadsadasdas< /strong > =to=> sadsadasdas (normal text)


Solution

  • Here's a kendoTextArea example for you in changing HTML to text. Try this in the DOJO. The HTML is changed into text after two seconds.

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8"/>
        <title>Kendo UI Snippet</title>
    
        <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.1.330/styles/kendo.default-v2.min.css"/>
    
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
        <script src="https://kendo.cdn.telerik.com/2021.1.330/js/kendo.all.min.js"></script>
    </head>
    <body>
      
    <textarea id="description" style="width: 100%;"></textarea>
    
    <script>
        $(document).ready(function(){
            var textArea = $("#description").kendoTextArea({
                value: "<b>Bold text</b>",
                rows:5,
                change: function(e) {
                    var value = e.sender.value();
                    e.sender.value($(value).text());
                },
            }).data("kendoTextArea");
    
            setTimeout(function() {
                textArea.trigger("change");
            }, 2000);
        });
    </script>
    </body>
    </html>