运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <form id="myForm" name="form1" action="/action_page.php"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> <input type="submit" value="Submit"> </form> <p>Click the "Try it" button to change the value of the name attribute in the form element.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myForm").name = "newName"; document.getElementById("demo").innerHTML = "The name of the form was changed from 'form1' to 'newName'."; } </script> </body> </html>