I have this function, which I would like to be executed after 5 seconds:
$(document).ready(function() {
$("#signInButton").trigger('click');
});
Thank you
Use setTimeout() function:
$(document).ready(function() {
setTimeout(function() {
$("#signInButton").trigger('click');
}, 5000);
});
Use setTimeout()
$(document).ready(function() {
setTimeout(function() {
$("#signInButton").trigger('click');
}, 5000); // for 5 second delay
});
$(document).ready(function() {
setTimeout(function() {
$("#signInButton").trigger('click');
}, 5000);
});
Something like this ?
$(document).ready(function() {
setTimeout(function() {
$("#signInButton").trigger('click');
}, 5000);
$("#signInButton").click(function(){
alert("I'm clicked!");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="signInButton" value="Click Me" />
Learn more about window's setTimeOut method
setInterval() that will call your function periodically i.e. every 10 mins or something, but the way you're asking like every 2 hours it should call some function, I don't think it will be good to use JavaScript because, in between that interval if user refresh the page then your script will be reset. Read more about setInterval() here, w3schools.com/jsref/met_win_setinterval.asp