I am trying to right a script for a notification popup. I wan't the popup to fade out after X seconds or fadeout when the user clicks on the message. I can get both effects to work individually but when I try to combine them fadeOut works. This is my code so far:
function notify(data, type) {
switch(type) {
case "success":
$('#notify').html(data)
.removeAttr("style")
.addClass('notifySuccess')
.click(function() {
$("#notify").fadeOut();
})
.delay(5000).fadeOut();
break;
case "error":
$('#notify').html(data)
.removeAttr("style")
.addClass('notifyFailure')
.click(function() {
$("#notify").fadeOut();
})
.delay(5000).fadeOut();
break;
}
}