[英]Javascript function how to wait some time before a function executes which takes the final value if there is a certain change during that time
[英]jQuery Set wait time before a function executes
如何設置此功能的等待時間。
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");
}
}
您可以使用setTimeout
:
setTimeout(function()
{
if($('#MedHistoryGridSec').is(':visible'))
alert('yes');
else
alert('no');
}, 3000);
您可以將代碼包裝在回調函數中,並在三秒鍾后使用window.setTimeout
運行它:
var afterThreeSeconds = function() {
if ($("#MedHistoryGridSec").is(":visible")) {
alert("yes we have grid");
}
else{
alert("No Grid");
}
}
window.setTimeout(afterThreeSeconds, 3000);
您是否可以使用包含要在該功能成功后執行的代碼的功能,向葯物歷史記錄網格函數添加參數,然后可以在葯物歷史記錄網格函數的末尾調用該代碼?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.