主题: KindEditor 如何获取纯文本的值呢?总说不支持text属性
作者: 张萧何, 发布日期: 2015-01-09 11:27:55, 浏览数: 3329
<!doctype html>
<html>
 <head>
  <meta charset="utf-8" />
  <title>Custom Theme Examples</title>
  <style>
   form {
    margin: 0;
   }
   textarea {
    display: block;
   }
  </style>
  <script charset="utf-8" src="../kindeditor-min.js"></script>
  <script charset="utf-8" src="../lang/zh_CN.js"></script>
  <script>
   KindEditor.ready(function(K) {
   
    K.each({
     'plug-align' : {
      name : '对齐方式',
      method : {
       'justifyleft' : '左对齐',
       'justifycenter' : '居中对齐',
       'justifyright' : '右对齐'
      }
     },
     'plug-order' : {
      name : '编号',
      method : {
       'insertorderedlist' : '数字编号',
       'insertunorderedlist' : '项目编号'
      }
     },
     'plug-indent' : {
      name : '缩进',
      method : {
       'indent' : '向右缩进',
       'outdent' : '向左缩进'
      }
     }
    },function( pluginName, pluginData ){
     var lang = {};
     lang[pluginName] = pluginData.name;
     KindEditor.lang( lang );
     KindEditor.plugin( pluginName, function(K) {
      var self = this;
      self.clickToolbar( pluginName, function() {
       var menu = self.createMenu({
         name : pluginName,
         width : pluginData.width || 100
        });
       K.each( pluginData.method, function( i, v ){
        menu.addItem({
         title : v,
         checked : false,
         iconClass : pluginName+'-'+i,
         click : function() {
          self.exec(i).hideMenu();
         }
        });
       })
      });
     });
    });
    K.create('#contentqq', {
     themeType : 'qq',
     items : [
      'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
     ]
    });
    editor = K.create('#contentqq', {
     allowFileManager: true
    });
    K('input[name=getText]').click(function (e) {
     alert(editor.text());
    });
   });
  </script>
  
 </head>
 <body>
  <h3>QQ风格</h3>
  <textarea id="contentqq" name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>
  <br />
  <input type="button"  name="getText"  value =" 提 交 " onclick="test()"/>
 </body>
</html>
作者: 张萧何, 发布日期: 2015-01-09 11:41:42

已经解决了~



<!doctype html>
<html>
 <head>
  <meta charset="utf-8" />
  <title>Custom Theme Examples</title>
  <style>
   form {
    margin: 0;
   }
   textarea {
    display: block;
   }
  </style>
  <script charset="utf-8" src="../kindeditor-min.js"></script>
  <script charset="utf-8" src="../lang/zh_CN.js"></script>
  <script>
   KindEditor.ready(function(K) {
   
    K.each({
     'plug-align' : {
      name : '对齐方式',
      method : {
       'justifyleft' : '左对齐',
       'justifycenter' : '居中对齐',
       'justifyright' : '右对齐'
      }
     },
     'plug-order' : {
      name : '编号',
      method : {
       'insertorderedlist' : '数字编号',
       'insertunorderedlist' : '项目编号'
      }
     },
     'plug-indent' : {
      name : '缩进',
      method : {
       'indent' : '向右缩进',
       'outdent' : '向左缩进'
      }
     }
    },function( pluginName, pluginData ){
     var lang = {};
     lang[pluginName] = pluginData.name;
     KindEditor.lang( lang );
     KindEditor.plugin( pluginName, function(K) {
      var self = this;
      self.clickToolbar( pluginName, function() {
       var menu = self.createMenu({
         name : pluginName,
         width : pluginData.width || 100
        });
       K.each( pluginData.method, function( i, v ){
        menu.addItem({
         title : v,
         checked : false,
         iconClass : pluginName+'-'+i,
         click : function() {
          self.exec(i).hideMenu();
         }
        });
       })
      });
     });
    });
    editor = K.create('#contentqq', {
     themeType : 'qq',
     items : [
      'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
     ]
    });
    K('input[name=getText]').click(function (e) {
     alert(editor.text());
    });
   });
  </script>
  
 </head>
 <body>
  <h3>QQ风格</h3>
  <textarea id="contentqq" name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>
  <br />
  <input type="button"  name="getText"  value =" 提 交 " />
 </body>
</html>

回复
发表新帖 发表回复