I have this function:
function flash(msg) {
var _id = $('#flash_notice__');
if( _id.length > 0 ) {
_id.html(msg);
} else {
$('<div id="flash_notice__">'+ msg +'</div>').appendTo('body');
//$('body').append('<div id="flash_notice__">'+ msg +'</div>');
}
setTimeout(function(){
_id.fadeOut(500, function(){
$(this).remove(); //or _id.remove();
});
}, 2500);
}
First time (on refresh) the message (msg) remain on page, then when flash() run again, works good. I think, when _id exist .remove() it's working, but when is create the the message it's still on screen. What I'm doing wrong? Thanks.