Skip to main content
 首页 » 编程设计

js实现三连击

2022年07月16日29davidwang456
<html> 
</head> 
<script> 
    function clickTime() { 
        var text_ = document.form.text_; 
        text_.value++; 
        var T = setInterval(() => { 
            text_.value = "0"; 
            clearInterval(T) 
        }, 1000); 
        if (text_.value == "3") { 
            alert("点击了三次"); 
            text_.value = "0"; 
        } 
    } 
</script> 
</head> 
 
<body onclick="clickTime()"> 
    <form name="form" style="margin:20px auto;width:15px;height: 15px;"> 
        <input type="button" name="text_" value=0 disabled style="margin:20px auto;width:28px;height: 20px;"> 
    </form> 
</body> 
 
</html>

本文参考链接:https://www.cnblogs.com/wulicute-TS/p/11971355.html