ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
> wangEditor2 版本过低,已停止维护。请使用 wangEditor 最新版本,参考[官网](https://www.wangeditor.com/)。 想要获取当前编辑区域的内容,可使用 `editor.$txt.html()` 和 `editor.$txt.text()` 获取。**注意,wangEditor 为 $txt 增加了一个`formatText`函数,用于获取格式化之后的纯文本,即 `editor.$txt.formatText()`** ```html <div id="div1"> <p>请输入内容...</p> </div> <button id="btn1">获取内容</button> <!--这里引用jquery和wangEditor.js--> <script type="text/javascript"> var editor = new wangEditor('div1'); editor.create(); $('#btn1').click(function () { // 获取编辑器区域完整html代码 var html = editor.$txt.html(); // 获取编辑器纯文本内容 var text = editor.$txt.text(); // 获取格式化后的纯文本 var formatText = editor.$txt.formatText(); }); </script> ```