HTML DOM click() 方法
定义和用法
click() 方法可模拟在按钮上的一次鼠标单击。
语法
- buttonObject.click()
实例
下面的例子将在 body onload 上模拟在按钮上的一次鼠标单击:
- <html>
- <head>
- <script type="text/javascript">
- function clickButton()
- {
document.getElementById('button1').click()
- }
- function alertMsg()
- {
- alert("Button 1 was clicked!")
- }
- </script>
- </head>
- <body
onload="clickButton()"
>- <form>
- <input type="button" id="button1" onclick="alertMsg()"
- value="Button 1" />
- </form>
- </body>
- </html>