Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display message for 3 seconds in javascript

setTimeout(function(){
     document.getElementById("alarmmsg").innerHTML=msg;
     },3000);

Above code is displaying message but not going off screen. What could be the problem?

like image 908
Nancy Avatar asked Jun 02 '16 14:06

Nancy


1 Answers

First display the message, then after 3 seconds delete it.

document.getElementById("alarmmsg").innerHTML = msg;

setTimeout(function(){
    document.getElementById("alarmmsg").innerHTML = '';
}, 3000);
like image 131
C14L Avatar answered Oct 21 '22 03:10

C14L