Jhonatan Rico Jhonatan Rico - 1 month ago 7
Javascript Question

Click a different button after clicking a button

I'm trying to auto-click a button in a page, but only after I manually clicked it first, the problem is that when the page loads, immediately the button starts to click and I need that it starts to click just after I make the first click

var $button = $('#start_autobet');
var maxWait = 3000;

function autoBet(){
console.log("Clickeando...");
$button.trigger('click');
}

setTimeout(function() { autoBet();}, getRandomWait());


I don't know how to make it start just after clicking.

Answer

This should work for you:

$('#start_autobet').on('click', function() {
 $(this).click();
});
Comments