執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Document Object</h1> <h2>The forms Property</h2> <form> <p>First Name: <input type="text" name="fname" value="Donald"></p> <p>Last Name: <input type="text" name="lname" value="Duck"></p> </form> <p>The number of form elements in the document is:</p> <p id="demo"></p> <script> let num = document.forms.length; document.getElementById("demo").innerHTML = num; </script> </body> </html>