setTimeout vs setInterval
this sliding animation works just fine with setInterval but doesn't work with setTimeout though i used setTimeout inside the function "scroll" so that it loops the function every time its been encountered
border:1px solid red;
<div id="div1"><img src="image1.jpg" ><img src="image2.jpg"><img src="image3.jpg"></div>
<div id="div2"><img src="image4.jpg" ><img src="image5.jpg"><img src="image6.jpg"></div>
document.getElementById("div1").style.left =m +"px";
document.getElementById("div2").style.left =n +"px";
setTimeout only fires the function passed as its argument once, then it dies of its own accord. setInterval keeps calling the function over and over again until it is stopped.
If you obtain a handle, either method can have its triggering ceased
the set time out has been given a function to call in 10 seconds but the very next line clears the timer because a handle was obtained that can then be used to clear the timer. The same procedure for setInterval is employed if you want some control over how many callbacks take place.
That will call the someFunc() function 10 times before clearing the call back.
c = c + 1;
console.log(">>> c="+c); // output to the browsers console
Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
I laughed that hard I burst my colostomy bag... (\\.\ May03)
Life for some is like a car accident... Mine is like a motorway pile up...
Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread