Jquery Loop Help
- Started
- Last post
- 12 Responses
- ESKEMA
I'm trying to get a function looped but I can't get it to work because I'm a noob.
example:
http://jsfiddle.net/Tj3mf/4/Help please thanks
- Pixter0
Must be recursive...
function changeColor(){
...after 1000ms, changeColor();
}
- ESKEMA0
could you edit the fiddle to make that work? I call the function already at the end, but maybe it is beeing called in the wrong place...
- Pixter0
just a sec
- Pixter0
Shit
I don't know if it's a problem with fiddle or jquery scope, but the recursion is not working
This is my code
http://jsfiddle.net/Tj3mf/6/
- Pixter0
All right now it's good
- Pixter0
Cleaned the outputs
http://jsfiddle.net/Tj3mf/10/
- ESKEMA0
Thanks!
just for reference, what was wrong with my code? I'm a noob at Javascript, so I know the stuff I do is not very optimized because of my limited coding skills, but it mostly works. Where should the recursive part have been to make the loop work?
- ESKEMA0
And how can I change the duration of the transition in that code?
- Pixter0
Your code wasn't wrong, but it wouldn't run indefinitely. To make it run "forever", you'd need to write a timed recursion (what I did) or use the setInterval function.
- Pixter0
In fact it is cleaner with setInterval
- ESKEMA0
I really need to take a JavaScript class...
Thanks
- ESKEMA0
Hey @dbloc, Codedademy is great!
just started their JS classes.
Already made a rock paper scissors game. Awesome!