HTML DOM click() 方法
定義和用法
click() 方法可模擬在按鈕上的一次鼠標(biāo)單擊。
語法
buttonObject.click()
實例
下面的例子將在 body onload 上模擬在按鈕上的一次鼠標(biāo)單擊:
<html> <head> <script type="text/javascript"> function clickButton() {document.getElementById('button1').click()
} function alertMsg() { alert("Button 1 was clicked!") } </script> </head> <bodyonload="clickButton()"
> <form> <input type="button" id="button1" onclick="alertMsg()" value="Button 1" /> </form> </body> </html>