<html> <head> <script type="text/javascript"> function alertId() { alert(document.getElementById("myButton").id) } </script> </head> <body> <form> <input type="button" value="Click me!" id="myButton" onclick="alertId()" /> </form> </body> </html>
结果:
编辑上面的代码,点击查看结果。
yige.org
- 试一个