<html> <head> <!--在這里字符集的設定很重要,如果設定不當將會出現亂碼--> <meta charset="UTF-8"> <title>wangEditor demo</title> </head> <body> <!--wangEditor是一款基於jquery框架開發的插件--> <script src="http://cdn.bootcss.com/wangeditor/2.1.20/js/lib/jquery-2.2.1.js"></script> <!--編輯器位置--> <div style="max-width:700px;margin:50px"> <div id="txtdiv" style="border:1px solid gray;min-height:240px"> </div> </div> <!--效果展示框--> <div id="show_box" style="border: 1px solid gray;margin-left:50px"></div> <!--腳本控制--> <script> $(function(){ //初始化編輯器 editor = new wangEditor("txtdiv"); editor.create(); //內容修改事件,此處做的是實時展示實際效果 editor.onchange = function(){ //獲取editor的html值 var html = editor.$txt.html(); $("#show_box").html(html) } }) </script> <!--按照官網上的說明,js和css的這兩個引用應該放在body的末尾--> <script src="http://cdn.bootcss.com/wangeditor/2.1.20/js/wangEditor.js"></script> <link href="http://cdn.bootcss.com/wangeditor/2.1.20/css/wangEditor.css" rel="stylesheet"> </body> </html>
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> </head> <body> <!-- body container --> <div class="container"> <div style="max-width:1100px;"> <!--demo--> <div style="text-align:left;"> <div id="divDemo"><p>歡迎使用<b>wangEditor 富文本編輯器</b>,請輸入內容...</p></div> </div><!--demo end--> </div> </div><!-- body container end --> <script type="text/javascript" src='http://www.wangeditor.com/js/jquery-1.10.2.min.js'></script> <script type="text/javascript" src='http://www.wangeditor.com/bootstrap-3.3.0/js/bootstrap.min.js'></script> <script type="text/javascript" src='http://unpkg.com/wangeditor/release/wangEditor.min.js'></script> <script type="text/javascript" src='http://www.wangeditor.com/index.js'></script> </body> </html>
http://www.wangeditor.com/