I want to use a method .delay()to wait 1 s before changing the contents of an element. I have a button on my page, and when the ajax request is executed, the diplays button is "done". After that, I want to wait 1 second and display "download". But the problem is that the βdownloadβ is displayed immediately after the βdoneβ without delay.
Here is my code:
$('#chocobo').click(function(){
$('#chocobo').html('<div id="banana" class="fa fa-refresh fa-spin"></div> Loading');
$.post("includes/modlist/pack.php",function(data){
$('#chocobo').addClass('done');
$('#chocobo').html('<div id="banana" class="fa fa-check"></div> Done');
$('#chocobo').delay(1000).html('<div id="banana" class="fa fa-refresh"></div> Download');
});
});
Can anybody help me?
source
share