GEM-I'm a dedicated Wordpress & Squarespace developer

Hide alert Message After Few Seconds With JQuery ?

Display an alert box after 20 seconds (20000 milliseconds):

To Hide alert Message use .hide in setTimeout

Tips:

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

Tip 1: 1000 ms = 1 second.

Tip 2: The function is only executed once. If you need to repeat execution, use the setInterval() method.

Tip 3: Use the clearTimeout() method to prevent the function from running.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> 
<script>
$(document).ready(function()
           {
waitingForOperator ='Custom Box Message-gemcode';
$('#box-msg').html(waitingForOperator);
setTimeout(function () {
$('#box-msg').hide(waitingForOperator);
                                    }, 20000);

           });
 </script>
<html>
<body>
<div id="box-msg">
    
</div>
</body>
</html>
Spread the Code

GEM

GEM

You may also like...