1 <!DOCTYPE html>
 2 <html>
 3 
 4     <head>
 5         <meta charset="UTF-8">
 6         <title></title>
 7         <style type="text/css">
 8             #num {
 9                 color: red;
10             }
11         </style>
12     </head>
13 
14     <body>
15 
16         <textarea class="weui_textarea" onkeyup="wordStatic(this);" maxlength="50" ></textarea>
17         <div class="weui_textarea_counter"><span >0</span>/50</div>
18 
19     </body>
20     <script type="text/javascript">
21         function wordStatic(input) {
22             // 获取要显示已经输入字数文本框对象
23             var content = document.getElementById('num');
24             if(content && input) {
25                 // 获取输入框输入内容长度并更新到界面
26                 var value = input.value;
27                 // 将换行符不计算为单词数
28                 value = value.replace(/\n|\r/gi, "");
29                 // 更新计数
30                 content.innerText = value.length;
31             }
32         }
33     </script>
34 
35 </html>
View Code

相关文章:

  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-12-15
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2021-12-15
  • 2021-05-18
  • 2021-10-23
  • 2021-12-15
  • 2021-10-31
  • 2022-02-04
相关资源
相似解决方案