gli Posted June 23, 2008 Share Posted June 23, 2008 Hi! I'm begginer to JavaScript. Heres my code var opacity = 0; function fadeout() { if(opacity <= 1) { opacity = opacity + 0.1; document.getElementById('imgMid').style.opacity=opacity; window.setTimeout('fadeout()', 60); } } It's working but only once, because i have slideshow, and on next picture, the opacity variable is 1, and i tried many ways but i can't get it work for all slideshow. Please can you give me way in what i can do that. Yes i tried 'for loops' and 'while' but nothing hapenned. Thanks Quote Link to comment Share on other sites More sharing options...
lemmin Posted June 23, 2008 Share Posted June 23, 2008 It would make sense to make a loop instead of recursively calling the function so that you can set the opacity variable each time the function is called. If you don't want to do that, I think it would work to just set the opacity back to 0 and return once the fade is done: var opacity = 0; function fadeout() { if(opacity <= 1) { opacity = opacity + 0.1; document.getElementById('imgMid').style.opacity=opacity; window.setTimeout('fadeout()', 60); } else opacity = 0; } Quote Link to comment Share on other sites More sharing options...
gli Posted June 25, 2008 Author Share Posted June 25, 2008 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.