js自动点击按钮:
<html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <button id="btn1">btn1</button> <button id="btn2">btn2</button> <button id="btn3">btn3</button> <button id="btn4">btn4</button> <div id = "btn11"></div> <div id = "btn22"></div> <div id = "btn33"></div> <div id = "btn44"></div> </body> <script type="text/javascript"> function b(){ var btn1 = window.document.getElementById("btn1"); var btn2 = window.document.getElementById("btn2"); var btn3 = window.document.getElementById("btn3"); var btn4 = window.document.getElementById("btn4"); var o1,o2,o3; btn1.onclick=function(){ a(1); o1 = setTimeout(() => { btn2.onclick(); }, 1000); } btn2.onclick=function(){ a(2); o2 = setTimeout(() => { btn3.onclick(); }, 1000); } btn3.onclick=function(){ a(3); o3 = setTimeout(() => { btn4.onclick(); }, 1000); } btn4.onclick=function(){ a(4); } btn1.onclick(); } function a(a){ document.getElementById("btn"+a+""+a).append("btn"+a); var o = "o"+a; clearTimeout(o); } b(); </script> </html>
标签:function,getElementById,js,btn4,点击,onclick,按钮,var,document From: https://www.cnblogs.com/shuilangyizu/p/16595930.html