In general, I need to slowly reduce transparency. The problem is that j ++ does not work with decimal numbers. In short, the fadeIn analog in jQuery

for(var j = 0.70; j < 0.90; j++){ this.style.background = 'rgba(250,250,250,' + j + ')' } // Это не правильно, но так понятнее будет , что я хочу сделать 

    1 answer 1

     for(var j = 70; j < 90; j++){ this.style.background = 'rgba(250,250,250,' + (j/100) + ')' } 

    UPD2 UPD3 (a small mistake made).
    But better

     var j = 70, me = this; var f = function f () { setTimeout(function() { j++; me.style.background = 'rgba(250,250,250,' + (j/100) + ')'; if (j < 90) { f(); } }, 100); }; f(); 
    • @ Anton Mukhin is blinking in my face now - Zow
    • What blinks?) And what browser. - Anton Mukhin
    • Well, I put your function on onmouseover and now it gets brighter then darker. Chrome Browser. Yes, and in the first version, it still quickly turns out very well ( - Zow
    • Something did not see the problem jsfiddle.net/GF6pS - Anton Mukhin
    • 2
      So you will create a timer 100 times, where are these expenses? - lampa