I have this message(); function:
function message(kind, text){
if(fadeOutDelay != undefined){
clearInterval(fadeOutDelay);
}
$("#message").show();
$("#message").attr('class',kind);
$('#message').text(text);
var fadeOutDelay = setInterval(function(){
$("#message").fadeOut(2000);
},10000);
}
The problem is that I am trying to clear the interval when the function is re-run to prevent a fading of the latest message. I want the ability to keep making messages occur and if they are 10 seconds within each other the fade not to occur. Basically, if there is a setInterval occurring at the time this function is being run I want to cancel it.
fadeOutDelayis not in the scope of other function calls. You could use a global variable instead: