0
我想實現簡單的toastr(通知)功能而不使用toastr插件。簡單的toastr通知消息
我想在5秒後刪除最後添加元素的過渡類。
var loadNotification = function(typeClass, message) {
var notification = {
typeClass: typeClass || 'alert-success',
message: message
};
var template = UTILS.getHandleBarTemplate('#template-notification');
var templateMarkup = template(notification);
$('.notifications-area').append(templateMarkup);
$('.notifications-area').find('.q-notifications').last().addClass('transitioned');
};
當前Implementaion:
刪除最後一個元素是不可預測的,因爲可能會添加新的通知,並且它會一直刪除添加的最後一個元素的類,這是錯誤的。所以我爲每個通知添加了一個ID。並在一定的時間間隔後移除該元素。 回答了我自己的問題:https://stackoverflow.com/a/44496961/6774615 –
@TabraizAli任何方式我認爲你需要setTimeout功能 –
感謝@Dinesh回答這個問題。幫助我達成解決方案 –