1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//获取按钮
var obu = document.getElementById("button");

//设置秒杀时间
var targetDate = new Date(2019,11,11,0,0,0);

//获取当前时间
var nowDate = new Date();

function check_click(){

nowDate = new Date();
if (nowDate >= targetDate){
obu.onclick();
}else{
setTimeout(check_click,100);//每100毫秒检测一次
}
}

check_click();