attributes





js/script.js
  • function funMake() {
  • for(var i=0, j=0; i<document.getElementById('f1').attributes.length; i++, j++) {
  •   document.write(document.getElementById('f1').attributes[i].nodeName+' : ');
  •   document.write(document.getElementById('f1').attributes[j].nodeValue+'<br />');
  •  }
  • }
  • function funMake() {
  • for(var i=0, j=0; i<document.getElementById('f1').attributes.length; i++, j++) {
  •   document.write(document.getElementById('f1').attributes[i].nodeName+' : ');
  •   document.write(document.getElementById('f1').attributes[j].nodeValue+'<br />');
  •  }
  • }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <form id="f1" action="#" method="post" name="form0">
  •   <input type="text" name="text0" />
  •   &nbsp;&nbsp;
  •   <input type="submit" name="perform" value="send" />
  •  </form>
  •  <br />
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <form id="f1" action="#" method="post" name="form0">
  •   <input type="text" name="text0" />
  •   &nbsp;&nbsp;
  •   <input type="submit" name="perform" value="send" />
  •  </form>
  •  <br />
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>