当前位置: 代码迷 >> 综合 >> 获取wangEditor编辑器的内容后,提交表单并获取编辑器的内容呢
  详细解决方案

获取wangEditor编辑器的内容后,提交表单并获取编辑器的内容呢

热度:15   发布时间:2024-01-26 22:09:27.0

坑-------------哎,不得不说,这个编辑器就是很漂亮,但是。。。。。。。。。

我是这样做的。。。。。。、

1.首先引入他的编辑器js

<script th:src="@{/static/assets/js/editorwang.js}"></script>
<script th:src="@{/static/assets/js/jquery.min.js}"></script>
</body>
<script type="text/javascript">var E = window.wangEditorvar editor = new E('#editor')// 或者 var editor = new E( document.getElementById('editor') )editor.create()//设置文本内容editor.txt.html($('#noplay').text())$('#submitedit').click(function () {alert(editor.txt.html())$('#text1').text(editor.txt.html());alert($('#text1').text())})
</script>

2.这是我在div中写的,其实就是隐藏div,然后回显给编辑器

<div class="am-form-group"><label for="editor" class="am-u-sm-3 am-form-label">文章内容</label><div id="editor" placeholder="请输入文稿内容" class="am-u-sm-9"></div><div style="display: none" name="newscontent"><textarea id="text1" style="width:100%; height:200px;" th:value="${selnews.newscontent}" name="newscontent"></textarea></div><div style="display: none" id="noplay">'这里面是你要回显的内容'</div></div>