SHOW:
|
|
- or go back to the newest paste.
1 | - | function startTimer(){ |
1 | + | var id = ["id1","id2","id3"]; //Array with the id's in the document you want to shuffle through |
2 | - | var x = 3000 //Timer |
2 | + | function resetValue() { |
3 | - | var i = 0 //Array element to use! |
3 | + | var i = 0; |
4 | - | var id = ["id1","id2","id3"]; |
4 | + | initiateTimer(); |
5 | - | if(x == 0){ |
5 | + | } |
6 | - | document.getElementById(id[i-1]).style.display = 'none'; |
6 | + | fuction initiateTimer() { |
7 | - | document.getElementById(id[i]).style.display = 'block'; |
7 | + | if(i > 3) { |
8 | - | } |
8 | + | resetValue(); |
9 | - | startTimer(); |
9 | + | } |
10 | - | } |
10 | + | var t = setTimeout(changeElement();, 5000)); //5000 = 5 seconds |
11 | } | |
12 | function changeElement() { | |
13 | document.getElementById(id[i-1]).style.display = 'none'; | |
14 | document.getElementById(id[i]).style.display = 'block'; | |
15 | i += 1; | |
16 | initiateTimer(); | |
17 | } |