如何使用Javascript在CKEditor中查找和替换文本?

时间:2011-04-12 12:25:03

标签: javascript jquery jquery-selectors ckeditor

如何使用Javascript在CKEditor中查找和替换文本? 谢谢你的建议!

1 个答案:

答案 0 :(得分:13)

试试这个

editor = CKEDITOR.instances.fck; //fck is just my instance name you will need to replace that with yours

var edata = editor.getData();

var replaced_text = edata.replace("idontwant", "iwant this instead"); // you could also use a regex in the replace 

editor.setData(replaced_text);

你可能想把它放在模糊事件或其他东西