Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show a div only for 3 seconds and disappear again using jquery?

i have my html like this

<p id="msgfail"  hidden="hidden" >Theres an error processing ur request</p>
<p id="sucessmsg"  hidden="hidden">Success fully update database</p>

when i click a button it triggers attempt to enter data to mysql database. and the corresponding p item is made visible. now my question is how do i make it dissapear again after a timeout ?

i tried it this way

if ($("#msgfail").is(":visible")) {
  setTimeout(function() {$("#msgfail").hide();}, 3000);
}
like image 375
jinni Avatar asked Nov 24 '25 02:11

jinni


1 Answers

Is something like this what you're thinking?

$("#msgfail").delay(3000).hide(1);

Docs for delay.

like image 163
Elliot Bonneville Avatar answered Nov 25 '25 15:11

Elliot Bonneville



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!