I'm having trouble to solve my problem of clicking 5 buttons using Jquery.
I want all 5 buttons clicked, but not at the same time. Instead, I want to execute a button called "Update All". After executing, I want that all 5 buttons get clicked 1 by 1, with 3 seconds gap, then stop at the 5th button.
Here is my code, but this code clicks all buttons, with no interval. So this won't work if the internet is really slow.
Thanks in advance for the Help.
By the way, this code was inside the while loop.
$(document).ready(function(){
$('#updateAll').click(function(){
setTimeout(function() {
$("#SubmitFormData<?php echo $chili_id; ?>").trigger('click');
}, 3000);
});
});
$(document).ready(function(){
$('#updateAll').on('click',function(){
var inputBtn=$('.saveBtn');
var C=0;
var setInter=setInterval(function(){
if( C==inputBtn.leangh)
clearInterval(setInter);
$(inputBtn[C]).click();
C++;
}, 3000);
});
$('.saveBtn').on("click",function(){
console.log($(this).val());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="updateAll" value="updateAll"/>
<br>
<input type="button" class="saveBtn" value="click 1"/>
<input type="button" class="saveBtn" value="click 2"/>
<input type="button" class="saveBtn" value="click 3"/>
<input type="button" class="saveBtn" value="click 4"/>
<input type="button" class="saveBtn" value="click 5"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With