需要使用富文本,推荐一款小巧方便的工具KindEditor
官方简介
KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。 KindEditor 使用 JavaScript 编写,可以无缝地与 Java、.NET、PHP、ASP 等程序集成,比较适合在 CMS、商城、论坛、博客、Wiki、电子邮件等互联网应用上使用。
官方网址: http://kindeditor.net/about.php
效果图
下载文件
下载最新版本的包,我下的是KindEditor 4.1.1,然后放到自己的工程下面,如图:
代码使用
分三步:
1. html
2. 引入标签库
3. js
1. html代码
<span class="w-fabu-lable2">房源详情:</span>
<textarea class="detail" id="houses.detail" name="houses.detail" style="width:700px;height:300px;">
</textarea>
2. 引入标签库
<!--富文本-->
<script charset="utf-8" src="../public/js/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="../public/js/lang/kindeditor/zh-CN.js"></script>
3. js
<script>
KindEditor.ready(function(K) {
window.editor = K.create('.detail');
});
</script>