W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <form id="frm1" action="/demo/html/action_page.php"> <button id="btn1" name="subject" type="submit" value="fav_HTML">HTML</button> <button id="btn2" name="subject" type="submit" value="fav_CSS">CSS</button> </form> <p>单击“试一试”按钮返回“HTML”按钮的值:</p> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("btn1").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>