<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Default Examples</title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script charset="utf-8" src="./kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="./kindeditor/lang/zh-CN.js"></script>
<script>
//KindEditor富文本编辑器样式初始化
KindEditor.ready(function(K) {
window.editor = K.create('#seditor');
});
</script>
</head>
<body>
<h3>默认模式</h3>
<textarea id="seditor" name="content" style="width: 800px; height: 400px;" οnkeyup="SwapTxt()">KindEditor</textarea>
<input value="点击获取编辑器的内容" onclick="getContent()" type="button">
<h3>展示区</h3>
<div id="show" style="border:1px solid red;width:600px;height:500px;word-break:break-all;"></div>
<script type="text/javascript">
function getContent(){
editor.sync();
$('#show').html($('#seditor').val());
}
</script>
</body>
</html>
像图片中这样,需要点击“点击获取编辑器的内容”按钮,下面展示区才会显示里面的内容,想要不通过按钮,直接div同步获取显示要怎么修改JS?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…