1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!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>