jQuery设置函数执行前的等待时间

HaB*_*aBo 1 javascript jquery time-wait

如何设置此功能的等待时间.

function UpdateMedicaitonHistory(data) {
     MedicaitonHistoryGrid();
//set a wait time to finish MedicaitonHistoryGrid() like for 3 seconds
// then execute the below code.
if ($("#MedHistoryGridSec").is(":visible")) {
            alert("yes we have grid");
      }
else{
     alert("No Grid");
    }
}
Run Code Online (Sandbox Code Playgroud)

Tej*_*ejs 9

你可以使用setTimeout:

setTimeout(function()
{
     if($('#MedHistoryGridSec').is(':visible'))
         alert('yes');
     else
         alert('no');
}, 3000);
Run Code Online (Sandbox Code Playgroud)