返回字符串的长度

  1. <html>
  2. <body>
  3.  
  4. <script type="text/javascript">
  5.  
  6. var txt="Hello World!"
  7. document.write(txt.length)
  8.  
  9. </script>
  10.  
  11. </body>
  12. </html>