如何使用Javascript在CKEditor中查找和替换文本? [英] How to find and replace text in CKEditor using Javascript?

查看:554
本文介绍了如何使用Javascript在CKEditor中查找和替换文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How could I find and replace text in CKEditor using Javascript? Thanks for your suggestion!

推荐答案

试试此

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

您可能想将其放在模糊事件或隐藏

you may want to put that in a blur event or soemthing

这篇关于如何使用Javascript在CKEditor中查找和替换文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆