Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Javascript查找和替换CKEditor中的文本?_Javascript_Jquery_Jquery Selectors_Ckeditor - Fatal编程技术网

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

如何使用Javascript查找和替换CKEditor中的文本?,javascript,jquery,jquery-selectors,ckeditor,Javascript,Jquery,Jquery Selectors,Ckeditor,如何使用Javascript查找和替换CKEditor中的文本? 谢谢你的建议 试试这个 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")

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

试试这个

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);

您可能想将其放入模糊事件或soemthing

@StanislasPiotrowski查看此链接@mcgrailm我不想将其放入模糊事件,我想替换其中的内容condition@mcgrailm,这仅替换一个实例。如何替换所有实例。@Abhijit。你必须创建一个循环来完成所有这些任务,这样你就必须知道你要如何瞄准他们。例如,给每个对象一个类,然后针对该类和循环。这有意义吗。