硬盤在人類的語言來解釋,只顯示代碼:無法點擊對方一再
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<script type="text/javascript">
function call_f1(){
document.getElementById('f1_div').click();
// document.getElementById('f1_div').click();
}
function f1(){
console.log('f1 '+new Date());
document.getElementById('btn_1').click();
}
</script>
</head>
<body>
<input id="btn_1" type="button" onclick="call_f1()" value="callf1"></input>
<div id="f1_div" onclick="f1()" style="background: red; width: 35px; height: 35px;">
</div>
</body>
當您使用鼠標單擊該按鈕,你得到的控制檯上的單一輸出。爲什麼??重複調用f1
函數嗎?
首先你爲什麼會想這樣做,其次,爲什麼不使用一個循環,如果你想要的是被記錄的日期? –
你確定* div *有* click()*方法嗎?你的遊戲機說什麼? –
@拉梅達鴨所有HTML元素都應該具有'click'功能:https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.click –