show message and disappear

How do I display a message for a few seconds and then disappear
2 Replies
Jochem
Jochem2y ago
have a normally hidden element, then to start showing your message show the element and set a timeout for x seconds to hide it again
#hiddenmessage {
display: none;
}
#hiddenmessage.show {
display: block;
}
#hiddenmessage {
display: none;
}
#hiddenmessage.show {
display: block;
}
<div id="hiddenmessage">Hello world</div>
<div id="hiddenmessage">Hello world</div>
document.querySelector('#hiddenmessage')?.classList.add('show');
setTimeout(()=>document.querySelector('#hiddenmessage')?.classList.remove('show'), 5000);
document.querySelector('#hiddenmessage')?.classList.add('show');
setTimeout(()=>document.querySelector('#hiddenmessage')?.classList.remove('show'), 5000);
or something
vert_Nk26☑
vert_Nk26☑2y ago
@jochemm thanks
Want results from more Discord servers?
Add your server