定义:
var waitUnitil=function (untillCallBack, nextStepCallBack, count) { if (count == null) { count = 0; } var timer = setInterval(function (ucb, ncb, c) { var checkResult = ucb(); if (c == 100 || checkResult) { clearInterval(timer); ncb(); interval = null; return; } console.log((c++) + "," + checkResult); }, 10, untillCallBack, nextStepCallBack, count); }
调用:
waitUnitil( function () { return walletContactInfoCreator.getEle$("#AddressInfo_City").find("option").length > 1; },//终止条件 function () { walletContactInfoCreator.getEle$("#AddressInfo_City").val(walletContactInfoCreator.entityV.AddressInfo.City).change(); }//下一步 )