富文本编辑器wangEditor
wangEditor是基于JavaScript和css开发的Web富文本编辑器。
wangEditor的使用:
引入wangEditor组件


wangEditor的读取与写入操作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--引入wangEditor-->
<script src="/resources/wangEditor.min.js"></script>
</head>
<body>
<div >
<button id="btnRead">读取内容</button>
<button id="btnWrite">写入内容</button>
</div>
<div id="divEditor" style="width: 800px;height: 600px"></div>
<script>
var E = window.wangEditor;
var editor = new E("#divEditor");//完成富文本编辑器初始化
editor.create();//创建富文本编辑器,显示在页面上
document.getElementById("btnRead").onclick = function () {
var content = editor.txt.html();//获取编辑器现有的html内容
alert(content);
}
document.getElementById("btnWrite").onclick = function (){
var content = "<li style='color:red'>我是<b>新内容</b></li>";
editor.txt.html(content);//设置编辑器的内容
}
</script>
</body>
</html>

浙公网安备 33010602011771号