How to click a browser button with JavaScript automatically?

后端 未结 6 1318
余生分开走
余生分开走 2020-12-02 18:18

How to click a button every second using JavaScript?

相关标签:
6条回答
  • 2020-12-02 18:48
    document.getElementById('youridhere').click()
    
    0 讨论(0)
  • 2020-12-02 18:55

    This will give you some control over the clicking, and looks tidy

    <script>
    var timeOut = 0;
    function onClick(but)
    {
        //code
        clearTimeout(timeOut);
        timeOut = setTimeout(function (){onClick(but)},1000);
    }
    </script>
    <button onclick="onClick(this)">Start clicking</button>
    
    0 讨论(0)
  • 2020-12-02 19:00

    this will work ,simple and easy

     `<form method="POST">
    <input  type="submit" onclick="myFunction()" class="save" value="send" name="send" id="send" style="width:20%;">
    </form>
    <script language ="javascript" >
    function myFunction() {
    setInterval(function() {document.getElementById("send").click();}, 10000);    
    }
    </script>
    

    `

    0 讨论(0)
  • 2020-12-02 19:02
    setInterval(function () {document.getElementById("myButtonId").click();}, 1000);
    
    0 讨论(0)
  • 2020-12-02 19:02

    This would work

    setInterval(function(){$("#myButtonId").click();}, 1000);
    
    0 讨论(0)
  • 2020-12-02 19:06

    You can use

    setInterval(function(){ 
        document.getElementById("yourbutton").click();
    }, 1000);
    
    0 讨论(0)
提交回复
热议问题