一、wangEditorjavascript
例子:html
<div id="div1">
<p>歡迎使用 <b>wangEditor</b> 富文本編輯器</p>
</div>
<textarea id="text1" style="width:100%; height:200px;"></textarea>//能夠隱藏textarea( display:none;)java
<script src="jquery.min.js"></script>
<script type="text/javascript" src="wangEditor.min.js"></script>
<script type="text/javascript">
var E = window.wangEditor
var editor = new E('#div1')
var $text1 = $('#text1')
editor.customConfig.onchange = function (html) {
// 監控變化,同步更新到 textarea
$text1.val(html)
}
editor.create()
// 初始化 textarea 的值
$text1.val(editor.txt.html())
</script>jquery
二、CKEditor (比較好用)編輯器
例子:網站
<script type="text/javascript" src="js/ckeditor/ckeditor.js"></script>spa
CKEDITOR.replace('textarea的name')
<td> <textarea id="opinion" name="opinion" rows="10" cols="38">${item.opinion}</textarea></td>code
<script type="text/javascript">htm
var opt =document.getElementById("opinion");ip
CKEDITOR.replace(opt)
</script>