<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>ueditor demo</title> <!-- 加载编辑器的容器 --> </head> <body> <div id="container" style="height: 500px;width: 800px" name="content"> </div> <button onclick="aaaa()"> 哈哈 </button> </body> <!-- 配置文件 --> <script type="text/javascript" src="ueditor.config.js"></script> <!-- 编辑器源码文件 --> <script type="text/javascript" src="ueditor.all.js"></script> <!-- 实例化编辑器 --> <script type="text/javascript"> let ue = UE.getEditor('container'); //对编辑器的操作最好在编辑器ready之后再做 ue.ready(function () { //设置编辑器的内容 //ue.setContent('hello'); //获取html内容,返回: <p>hello</p> var html = ue.getContent(); //获取纯文本内容,返回: hello var txt = ue.getContentTxt(); }); function aaaa() { let html = ue.getContent(); alert(html) } </script> </html>