空 CKEditor -TextArea

Empty CKEditor -TextArea

我想在 CKEditor 中清空我的文本区域。
我可以使用 SetData(' ') 清除 TextArea,但只能在页面加载后清除一次。

我只在 Onchange 事件中写了 jquery 函数。

  <%= Html.TextArea("AutoTextNotes", (consentForm != null && consentForm.Notes != null) ? CommonUtil.decodeHTML(consentForm.Notes) : "", new { id = "AutoTextNotes", validateRequest = "false", style = "width: 75%;height: 500px !important;", @class = "fck", onchange = "RemoveValidation('Error_AutoTextNotes');" })%>

Jquery 函数:-

function RemoveValidation(ErrorID) {
        debugger;
        $("#" + ErrorID).css("display", "none");
        var fck_instance = FCKeditorAPI.GetInstance('AutoTextNotes');
        var imf = fck_instance.GetHTML();
        if (imf.contains("<img")) {
            alert("Sorry, Image Is Not Supported For This TextArea");
            fck_instance.Config.BodyClass = 'shobi';
            fck_instance.SetData('');

            }
         }

如果我可以删除 TextArea 中的所有图像标签,这也会很有帮助。

你可以尝试使用

$("#id-textarea").val("");