在html中有引用kindeditor编辑器。
<textarea id="editor_id" name="content" onkeyup="show()" style="width:1200px;height:430px;"></textarea>
然后打开网页,在编辑器里面输入了一些数字文字,想在旁边一个div框中显示出来,但是获取不到,这是div的代码:
<div id="content" class="preview" style="position: absolute; left: 0px; bottom: 30px; right: 0px; top: 60px; z-index: 10; padding: 20px 10px; overflow: hidden auto; word-break: break-all;"></div>
这是JS代码:
<script charset="utf-8" src="./editor/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="./editor/kindeditor/lang/zh-CN.js"></script>
<script>
//初始化KindEditor富文本编辑器
KindEditor.ready(function(K) {
window.editor = K.create('#editor_id');
});
/*var editor_id=document.getElementById("editor_id");
var content=document.getElementById("content");
editor_id.onkeyup=function(){
content.innerText=editor_id.value;
}*/
function show(){
document.getElementById('content').innerHTML=document.getElementById('editor_id').value;
}
</script>
我这样写两个JS方法都获取不到textarea里面的值,该如何获取kindeditor富文本编辑器里面的值,然后在旁边div中的content同步显示出来?