Call a function every second or 5 seconds in javascript

setinterval
function calling

call a javascript function every 5 seconds continously.  You can use setInterval(). The below code is working from onload.

setInterval(test,5000);
function test()
{
	alert("hi");
}

 

 

You might also like:

How to get current date and time (yyyy-mm-dd H:i:s) using javascript

09-03-2017 javascript date time

Using slice remove last two characters from given string

07-03-2017 slice remove

Get next date from given date in javascript

06-03-2017 date javascript next date

Sample Validations in javascript

22-02-2017 validations javascript

Get random strings from given string In javascript

21-02-2017 javascript random string