document.forms example
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> #result{ color: red; font-size: 20px; font-weight: bold; } </style> </head> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <form action="#" method="POST"> Username: <input type="text" name="fname" placeholder="Nhập Username"><br> Email: <input type="text" name="lname" placeholder="Nhập Email"> </form> <p id="result"></p> <button onclick="myFunction()">Xem kết quả</button> <script> function myFunction(){ var length = document.forms.length; document.getElementById("result").innerHTML = "Số thẻ 'form' tồn tại trên trang: " + length; } </script> </body> </html>
PHÓNG TO