I've created two functions called 'FadeIn' and 'FadeOut' because i can't use jQuery but they don't work, i don't know why. They directly set the opacity to 0 or 1 without doing it gradually. This is the code:
function fadeIn(el){
var val = 0;
document.getElementById(el).style.opacity = val;
function fade(){
val += .1;
document.getElementById(el).style.opacity = val;
if (val < 1){
setTimeout(fade(), 90);
}
}
fade();
}
function fadeOut(el){
var val = 1;
document.getElementById(el).style.opacity = val;
function fade(){
val -= .1;
document.getElementById(el).style.opacity = val;
if (val > 0){
setTimeout(fade(), 90);
}
}
fade();
}