word-count.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Word Count Examples</title>
  6. <style>
  7. form {
  8. margin: 0;
  9. }
  10. textarea {
  11. display: block;
  12. }
  13. </style>
  14. <link rel="stylesheet" href="../themes/default/default.css" />
  15. <script charset="utf-8" src="../kindeditor-min.js"></script>
  16. <script charset="utf-8" src="../lang/zh_CN.js"></script>
  17. <script>
  18. KindEditor.ready(function(K) {
  19. K.create('textarea[name="content"]', {
  20. afterChange : function() {
  21. K('.word_count1').html(this.count());
  22. K('.word_count2').html(this.count('text'));
  23. }
  24. });
  25. });
  26. </script>
  27. </head>
  28. <body>
  29. <h3>统计字数</h3>
  30. <form>
  31. <textarea name="content" style="width:800px;height:200px;"></textarea>
  32. <p>
  33. 您当前输入了 <span class="word_count1">0</span> 个文字。(字数统计包含HTML代码。)<br />
  34. 您当前输入了 <span class="word_count2">0</span> 个文字。(字数统计包含纯文本、IMG、EMBED,不包含换行符,IMG和EMBED算一个文字。)
  35. </p>
  36. </form>
  37. </body>
  38. </html>