查找表单中的元素数量

  1. <html>
  2. <body>
  3.  
  4. <form id="myForm" method="get">
  5. Name: <input type="text" size="20" value="Bill Gates" /><br />
  6. Text: <input type="text" size="20" value="Hello World" />
  7. </form>
  8.  
  9. <script type="text/javascript">
  10. document.write("Number of elements in myForm: ");
  11. document.write(document.getElementById('myForm').length);
  12. </script>
  13.  
  14. </body>
  15. </html>