I'm a beginner to coding and I've been trying to delay a button click function using timeout but it seems like not working.
To clarify it further, this button is supposed to do something, but when I add timeout function all it does is just delay it and not processing to the next line. Even with JavaScript is okay. Can anyone help me out. Thanks in advance. :)
$(document).ready(function () {
setTimeout(function(){
$("#mybutton").click(myButtonClicked);
}, 1000);
getURLParameter("run") && $("#mybutton").click()
});
function getURLParameter(a) {
a = (new RegExp("[?|&]" + a + "=([^&;]+?)(&|#|;|$)")).exec(location.search);
if (null == a) return null;
a = a[1];
a = a.replace(/\+/g, "%20");
return decodeURIComponent(a)
}
function myButtonClicked() {
disableMyButton();
var a = $(".new").toArray(),
c = $(".status").toArray();
a.reverse();
c.reverse();
doNextBox(a, c)
}
What I'm trying to do is
- Click button
- Wait a second
- Proceed to the next task