3
I did a function to fade out on <div>
once I finish loading the page but can’t get the exact value of the end of Fadeout (that would be 0) always gives me a number like this: 0.009999999999247;
How can I subtract correctly and get 0?
function fadeOut(id){
//pega o elemento da página
obj = document.getElementById(id);
//seta a opacidade como 0
obj.style.opacity = 1.00;
fazFadeOut = function (){
if(obj.style.opacity != 0){
var atual = Number(obj.style.opacity);
var newopac = atual - Number(0.01);
obj.style.opacity = String(newopac);
if(obj.style.opacity == 0){
obj.style.display = 'none';
}
setTimeout('fazFadeOut()', 10);
}
}
fazFadeOut();
}
the expression
atual - Number(0.01)
that returns you0.00999...
?– Paulo Roberto Rosa
@Paulo Sim, was to set the opacity of <div> 0 but give me this 0.009999999999999247
– Odair
This is actually a stopgap. Money should not be represented in this way: https://answall.com/q/110463/101.
– Maniero