Hi all,
I asked a question a couple weeks ago about using setTimeout for a factorial function, but it was unfortunately with an unregistered account and I never got a complete answer.
My main issue is that I'd like to write a function that calculates the factorial of a number but uses the setTimeout or setInterval commands. The impetu...
How do I call a given function every X seconds ? In this case i made a function that scrolls some images . I want the image to change based on a given interval of time ex every 5 seconds but i really have no idea :/ some suggestions and good practice for this ? Thank you.
...
Hello people. In using javascript i noticed this thing. You can use
var i=0;
var startingTime=new Date().getTime();
setInterval("foo()",1);
function foo() {
i+=1;
if ($("#foodiv").text()==i) {
//we detected a doubled value (parallel execution)
$("#repdiv").append("[repetition on "+i+"]");
}
$("#foodiv")....
basically i have a blank html page that includes a javascript file, and in the javascript file i have this:
function doIt() {
document.writeln("asdf");
}
// could also be setTimeout
setInterval("doIt()", 5000);
When the html page loads, it waits 5 seconds and then will output "asdf" every 5 seconds to the screen. If i hit refresh or...
I am trying to set an interval when some code runs but only need to do it based on the number of elements there are. Here's a quick example:
5 total elements
Run code once every 20 seconds for each element that is found.
Can someone please give me a basic example how to do this using plain JavaScript? Everything I have tried just exec...