I'm a beginner with JavaScript and doing some exercise. When I add a new movie a notification is showing up after 0.5seconds, but I'm not sure afterward how can I set a time-interval of 2 seconds to hide the notification. Any help is appreciated!
// Notification function notify(){ setTimeout(function(){ document.getElementById('notificationAddMovie').style.display = 'block'},500); }
/* Notification */ #notificationAddMovie{ display: none; position:fixed; padding:1rem; bottom:10px; left:10px; background-color:#621940; color:#FFF; font-family: helvetica; border-radius:3px; }
<!-- Movie Add Box--> <div id = 'notificationAddMovie'> <p>Successfully added!</p> </div>
function notify(){
setTimeout(function(){
document.getElementById('notificationAddMovie').style.display = 'block'
}, 500);
setTimeout(function(){
document.getElementById('notificationAddMovie').style.display = 'none'
}, 2000);
}
Is that what you need?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.