I'm trying to implement a notification style JQuery function. Here's what I have so far
function notify(message, type, autohide, delay) {
message = message;
type = type || "";
autohide = autohide || false;
delay = delay || 0;
$('#notification-container').append("<div class='notice " + type + "'>" + message + "<div class='close-container'><span class='glyphicon glyphicon-remove'></span></div></div>");
};
Calling this function adds the notification correctly but I haven't been able to make that specific element be removed after 'delay' period of time without removing all the other notifications. I've search but have only found #id based solutions or class based. I don't want to have to put ids on each new notification and if I remove it by .notice, all notifications will expire at the same time. The closest I've gotten has been to use
if (autohide) {
setTimeout(function () {
$('#notification-container .notice:last-child').remove();
}, delay);
}
But I'm sure all of you can see how that's flawed. Any help or suggestions would be appreciated.