Anne Schwarz Anne Schwarz - 9 days ago 7
Javascript Question

jQuery - wait half second between specific steps inside function

I got this function:

function selectkontakt(z){
$("#loadnew").empty();
$("#loadold").empty();
// I need half second pause here before it goes on
kontakte();
$("#textarea").show();
}


In the comment you can see where I need a half second pause before it goes on, is that possible?

Answer

Just use a timeout

function selectkontakt(z){
    $("#loadnew").empty();
    $("#loadold").empty();
    setTimeout(function() {
        kontakte();
        $("#textarea").show();
    }, 500);
}