I am using JavaScript with jQuery. I have the following script to alert hi
every 30 seconds.
$(document).ready( function() {
alert(\"hi\");
Wrap your code in a function. Then, pass the function as a first argument to setInterval
, and call the function:
$(document).ready( function() {
//Definition of the function (non-global, because of the previous line)
function hi(){
alert("hi");
}
//set an interval
setInterval(hi, 30000);
//Call the function
hi();
});