运行 ❯
获取您
自身
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往空间
<!DOCTYPE html> <html> <body> <form id="myForm" 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 set the value of the target attribute in the form to "_blank".</p> <p><b>Note:</b> Click "Submit" before and after you have clicked on the "Try it" button.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myForm").target = "_blank"; document.getElementById("demo").innerHTML = "The value of the target attribute was changed."; } </script> </body> </html>