css - How to shift opacity via i in JavaScript? -


i trying make to-top button, well, after few pix scroll, let 1000, show up. popular button suppose these days.

anyhow, worked , d add shifting opacity property element after show up, observed few websites, , 1 of them use algorithm shift 0 1, d make simple not know algorithm, below code.

if(navbarscroll > 1000){     totopele.style.visibility = "visible";     totopele.style.pointerevents = "auto";     for(var = 0; < 1; += 0.1){         totopele.style.opacity = "i";     }; }; 

anyhow, after event, did not work, , there isn't opacity property on element @ all.

so, wrong here?

btw, if kind give solution, plz no jquery, learning pure js :)

thanks time.

as comments state, correct syntax

totopele.style.opacity = i; 

however efftect not wish? probalby faded in instance, instead of on time. need timer fade slowly, or css animation


Comments