清空CKEditor -TextArea

时间:2016-02-04 10:08:02

标签: javascript jquery jquery-plugins ckeditor

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

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

  <%= 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中的所有图像标记。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用

$("#id-textarea").val("");
相关问题