In jquery Set a delay to fade out or fadeout right away on click
Posted
by JClu
on Stack Overflow
See other posts from Stack Overflow
or by JClu
Published on 2010-05-20T13:22:24Z
Indexed on
2010/05/20
13:30 UTC
Read the original article
Hit count: 176
jQuery
|notifications
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;
}
}
© Stack Overflow or respective owner