JQuery doing div fadeout with timer

Looking to make a fading div after 10 seconds.

I tried different things, but could not get the timer to work.

This is the code:

$('#deletesuccess').show(); 

Edit:

This is the full code:

  function refreshTable() { //timestamp to get around ie caching issue var tsTimeStamp= new Date().getTime(); $('#deletesuccess').show().fadeOut(); $.get('table.php', {action: "get", time: tsTimeStamp}, function(data){ $('#customertable').html(data).fadeIn(); }); return true; } 

I need to show the div and then hide it after x seconds.

+4
source share
2 answers

Easy way in 1.4:

 $('#deletesuccess').delay(10000).fadeOut(); 

You can also interrupt this if necessary:

 $('#deletesuccess').stop(true, true); 
+12
source

Use setTimeout for this.

 setTimeout(function(){ $("#deletesuccess").fadeOut("slow"); }, 10000 ); 
+9
source

Source: https://habr.com/ru/post/1303794/


All Articles