$("#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();