jQuery富文本编辑器插件wysiwyg.js使用攻略

 时间:2024-10-11 19:01:35

1、<link rel="stylesheet" type="text/css" href="css/wysiwyg-editor.css" /> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/wysiwyg.js"></script> <script type="text/javascript" src="js/wysiwyg-editor.js"></script>

jQuery富文本编辑器插件wysiwyg.js使用攻略

2、HTML结构如下图所示: <textarea id="editor1" name="editor" placeholder="Type your text here..."></textarea>

jQuery富文本编辑器插件wysiwyg.js使用攻略

3、// create wysiwyg:var wysiwygeditor = wysiwyg({e盟敢势袂lement: docum髫潋啜缅ent.getElementById('editor-id'),onkeypress: function( code, character, shiftKey, altKey, ctrlKey, metaKey ) {},onselection: function( collapsed, rect, nodes, rightclick ) {},onplaceholder: function( visible ) {},hijackcontextmenu: false});// properties:wysiwygeditor.getElement();wysiwygeditor.getHTML(); -> 'html'wysiwygeditor.setHTML( html );wysiwygeditor.getSelectedHTML(); -> 'html'|false// selection and popup:wysiwygeditor.collapseSelection();wysiwygeditor.openPopup(); -> popup-handlewysiwygeditor.closePopup();// exec commands:wysiwygeditor.removeFormat();wysiwygeditor.bold();wysiwygeditor.italic();wysiwygeditor.underline();wysiwygeditor.strikethrough();wysiwygeditor.forecolor( '#color' );wysiwygeditor.highlight( '#color' );wysiwygeditor.fontName( fontname );wysiwygeditor.fontSize( fontsize );wysiwygeditor.subscript();wysiwygeditor.superscript();wysiwygeditor.align( 'left'|'center'|'right'|'justify' );wysiwygeditor.format( tagname );wysiwygeditor.insertLink( 'http://url.com/' );wysiwygeditor.insertImage( 'http://url.com/' );wysiwygeditor.insertHTML( 'html' );wysiwygeditor.insertList( ordered );

4、var $editor = $('#e蟠校盯昂ditor').wysiwyg({classes: 媪青怍牙'some-more-classes',toolbar: 'selection'|'top'|'top-selection'|'bottom'|'bottom-selection',buttons = { ... },submit = { ... },placeholder: 'Type your text here...',dropfileclick: 'Click or drop image',placeholderUrl: 'www.example.com',maxImageSize: [width,height],onImageUpload: function( insert_image ){},onKeyEnter: function(){}})Properties:$editor.wysiwyg('container'); -> $(container-div)$editor.wysiwyg('shell'); -> wysiwyg.js APIEvents:.focus(function(){}).blur(function(){}).change(function(){});

jQuery富文本编辑器插件wysiwyg.js使用攻略

5、运行效果如下图所示:

jQuery富文本编辑器插件wysiwyg.js使用攻略

6、浏览器兼容性,如下图所示:

jQuery富文本编辑器插件wysiwyg.js使用攻略
  • 宜昌三游洞,前有三人同游留美称
  • 销赃罪怎么判刑
  • 最强蜗牛飞碟怎么触发
  • WORD怎样给图片边缘做模糊效果
  • word如何设置图片透明度
  • 热门搜索
    防震减灾手抄报资料 电子手抄报模板下载 安全手抄报的图片 纪念英雄手抄报 劳动节手抄报简单一点 三爱三节手抄报资料 科学知识手抄报 缅怀先烈的手抄报图片 尊师重教手抄报 民族文化手抄报