getAttribute()





js/script.js
  • function funMake() {
  •  document.write(document.getElementById('f1').getAttribute('method'));
  • }
  • function funMake() {
  •  document.write(document.getElementById('f1').getAttribute('method'));
  • }


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">
  •   <input id="txt1" type="text" />
  •   <br />
  •   <br />
  •   <input id="b1" type="submit" name="perform" value="OK" />
  •  </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">
  •   <input id="txt1" type="text" />
  •   <br />
  •   <br />
  •   <input id="b1" type="submit" name="perform" value="OK" />
  •  </form>
  •  <br />
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>