JavaScript 参考手册
Submit name 属性
下面的例子可显示出该确认按钮的名称
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function displayResult() { var x = document.getElementById("submit1").name; alert(x); } </script> </head> <body> <form> Email: <input type="text" id="email"> <input type="submit" name="submit1" id="submit1"> </form> <button type="button" onclick="displayResult()">显示提交按钮的名称</button> </body> </html>
运行结果:
点击运行 »