首页 > 其他分享 >js自动点击按钮

js自动点击按钮

时间:2022-08-17 17:25:47浏览次数:45  
标签:function getElementById js btn4 点击 onclick 按钮 var document

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

相关文章

  • Notepad++ 怎么以json格式显示数据 notepad++怎么安装JSON Viewer插件
    Notepad++安装JSONViewer插件,就可以以json格式显示数据,点击插件-->插件管理;  弹出的插件管理窗口,在“可用”栏目的搜索框写入“JSONViewer”会自动搜到该插件......
  • js算法基础-栈结构的封装和进制转换
    先是栈结构的封装,使用es6的方式。#items为栈结构#表示类的私有属性,外部不能直接访问和修改。push压栈pop出栈peek查看栈顶isEmpty栈是否为空size栈内元素个数......
  • Js中的枚举
    在JavaScript目前的版本中,没有枚举这个概念(当然,ECMA-262第三版中已经将enum作为关键字保留)。然而,如同JavaScript中没有class一样,但我们仍然可以通过间接的方式——JSON来......
  • JS判断数组中是否存在某个值或者某个对象的值
    、判断是否存在某个值1、Array.prototype.indexOf()indexOf()方法返回在数组中可以找到一个给定元素的第一个索引,如果不存在,则返回-1。constbeasts=['ant','......
  • Nodejs 多进程与多线程
    为什么要使用多进程多进程与多线程介绍Nodejs多进程和多线程使用与区别cluster为什么需要多进程nodejs单线程,在处理http请求的时候一个错误都会导致进程退出,这是灾......
  • 记录:excel导入导出js-xlsx,处理合并
    效果前情提要后端传excel坐标数据,前端自己处理模板,找资料后,选择直接载入xlsx方式。准备工作npmixlsximport*asXLSXfrom'xlsx'导入提取数据letreader......
  • [JSOI2007] 字串加密
    题链:luoguJS同学?Description让JS同学对环形字符串进行重组加密。加密规则是:列出\(n\)个字符串并字典序升序,一次取末尾字符作为加密后的长度为\(n\)的密码串。......
  • 原生get请求读取本地json文件,electron vue
    1readLocalFile(fileUrl){2letxhr=null3if(window.XMLHttpRequest){4xhr=newXMLHttpRequest()5}else{6/......
  • a菜单点击标红,其他标黑代码
    <script>letaList=document.querySelectorAll('a');console.log(aList);for(letindex=0;index<aList.length;index++){......
  • JSP内置对象、MVC开发模式
    JSP内置对象内置对象:在jsp页面中不需要创建,直接使用对象变量名  真实类型  作用*pagecontext......