国产精品人成在线播放新网站,欧洲吸奶大片在线看,亚洲欧洲成人a∨在线,国产18禁黄网站免费观看

微信號:
當前位置:首頁 > 資訊文摘 > 新聞資訊

ckeditor獲取純文本,ckeditor過濾html代碼

2015/6/18 23:12:12

$("#submit").click(function () {
             /* CKEDITOR.replace("editor1"); */
             var title = $("#caption").val(); /*不能用.text()或.html()*/
             var val = CKEDITOR.instances.editor1.getData();
             var content = editor.document.getBody().getText();
             /* var editor = CKEDITOR.replace("editor1");
            editor.document.getBody().getText(); //取得純文本
            editor.document.getBody().getHtml(); //取得html文本
             var valText = CKEDITOR.instances.editor1.EditorDocument.body.innerText(); */
            if (title.length == 0 || val.length == 0) {
                       alert("標題或內(nèi)容不能為空");
             } else {
                      alert("標題:" + title + "內(nèi)容" + content + "html內(nèi)容:" + val);
                          }
});


1、獲取CKEditor被選中的內(nèi)容
var mySelection = CKEDITOR.instances.ckStem.getSelection();
if (CKEDITOR.env.ie) {
                 mySelection.unlock(true);
                 data = mySelection.getNative().createRange().text;
} else {
                  data = mySelection.getNative();
}


2、獲取CKEditor純文本
var stemTxt=CKEDITOR.instances.CKEditor1.document.getBody().getText(); //取得純文本


3、獲取CKEditor帶HTML標簽的文本
var stem = CKEDITOR.instances.CKEditor1.getData();

相關(guān)新聞: