Jquery making div fadeout with timer

user289554 picture user289554 · Mar 11, 2010 · Viewed 14.2k times · Source

Looking to make a div fadeout after 10 seconds.

Tried various things but can't get the timer working.

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 amount of seconds.

Answer

Nick Craver picture Nick Craver · Mar 11, 2010

An easy way in 1.4:

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

You can also abort this easily if needed:

$('#deletesuccess').stop(true, true);