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

Kya*_*ein 5 javascript jquery jquery-selectors ckeditor

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

mcg*_*ilm 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);
Run Code Online (Sandbox Code Playgroud)

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