I would to apply a fadeIn effect to a addClass function..and fadeOut to removeClass...
Can you help me?
This is my code
$('#loader'+idTurno).addClass('loader');
...
$('#loader'+idTurno).removeClass('loader');
I would to apply a fadeIn effect to a addClass function..and fadeOut to removeClass...
Can you help me?
This is my code
$('#loader'+idTurno).addClass('loader');
...
$('#loader'+idTurno).removeClass('loader');
Fade In:
$("#loader").fadeIn("slow", function() {
$(this).addClass("loader");
});
Fade Out:
$("#loader").fadeOut("slow", function() {
$(this).removeClass("loader");
});
As another user said, you may want to look into using toggleClass
.
fadeOut()
. It talks about how after the opacity is set to 0, the display property is set to display: none
- api.jquery.com/fadeout –
Derogative Another way to achieve that, using your original jQuery code, the CSS way :
#loader {
transition: opacity 500 ease-in-out;
}
Smoother animation, easier to maintain.
.loader
which will set the opacity to 0 or 1. Then toggle this class with JS. –
Schoenfelder Perhaps used setTimeout function after fadeIn class
$('#loader').addClass('loader').fadeIn('slow');
setTimeout(function(){ $('#loader').removeClass('loader'); }, 1000);
Make it simple :
$('#loader'+idTurno).addClass('loader').fadeIn(1000);
$('#loader'+idTurno).removeClass('loader').fadeIn(1000);
You should add a duration to the remove/addClass method:
$('#loader'+idTurno).addClass('loader',500);
$('#loader'+idTurno).removeClass('loader',500);
duration
property for the $.addClass()
or $.removeClass()
methods. –
Globe © 2022 - 2024 — McMap. All rights reserved.