Hide alert Message After Few Seconds With JQuery ?

Last updated on April 21st, 2020 at 02:47 am

Reading Time: < 1 minute

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

Author

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *