I've been trying for a week and spent endless hours on a tiny little code, and I cannot take any more of it so please help... code nr 1. not working, but I think should:
$(document).ready(function(){ $("#logo").css('opacity','0.01'); for (var i = 10000; i>0; i-=100) { setTimeout(function() { $("#logo").fadeTo("fast",1-i/10000); $("#percentage").html(i/100 + '%'); },i); } }); Code nr 2. not working, but I think should (it's supposed to do the same thing as the one above): function changeFade(i) { $("#logo").fadeTo("fast",1-i/10000); $("#percentage").html(i/100 + '%'); i += 100; if (i<=10000) setTimeout(changeFade(i),100); } $(document).ready(function(){ alert('test'); $("#logo").css('opacity','0.01'); changeFade(100); } I have to <div> and I start out by rendering one of them invisible, then I continually update the percentage as the image fades in. What is wrong with this?