日期:2014-05-16 浏览次数:20391 次
<textarea name="textarea" id="textarea" ><b>要初始化的内容</b></textarea>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$.fn.myeditor = function (options) {
var defaults = {
width: "100", height: "100"
}
var newset = $.extend(defaults, options)
return this.each(function () {
var div = $('<div></div>')
.css({ width: defaults.width, height: defaults.height, border: 'solid 1px black' })
.attr('contentEditable', true).html($(this).val());
$(this).hide().after(div);
});
}
$("#textarea").myeditor({ width: "300" });
</script>