该代码用于查找TextArea,所使用的逻辑是代码需要等待5000,然后调用该函数。.但是它不能按预期工作...
function getTextArea(ObjQuestion, objAnswer) {
debugger;
objText = $('label:contains("' + objAnswer + '")').siblings('span').children('input[name*="' + ObjQuestion + '"]').parentsUntil("div .xsk").parent('div').parent('div').next('div').find('textarea');
if (objText.length === 1) {
return objText;
} else {
if (tries >= 5) {
console.log('failed');
tries = 0;
} else {
console.log('getTextArea' + tries + new Date());
tries++;
setTimeout(getTextArea(ObjQuestion, objAnswer), 50000);
}
}
}
这是console.log的详细信息
testChekBox
script.js:261 getTextArea0Wed Mar 06 2019 14:27:28 GMT+0530 (India Standard Time)
script.js:261 getTextArea1Wed Mar 06 2019 14:27:30 GMT+0530 (India Standard Time)
script.js:261 getTextArea2Wed Mar 06 2019 14:27:31 GMT+0530 (India Standard Time)
script.js:261 getTextArea3Wed Mar 06 2019 14:27:35 GMT+0530 (India Standard Time)
script.js:261 getTextArea4Wed Mar 06 2019 14:29:52 GMT+0530 (India Standard Time)
script.js:258 failed
script.js:194 testChekBox
script.js:261 getTextArea0Wed Mar 06 2019 14:29:58 GMT+0530 (India Standard Time)
script.js:261 getTextArea1Wed Mar 06 2019 14:29:58 GMT+0530 (India Standard Time)
script.js:261 getTextArea2Wed Mar 06 2019 14:29:58 GMT+0530 (India Standard Time)
script.js:261 getTextArea3Wed Mar 06 2019 14:29:59 GMT+0530 (India Standard Time)
script.js:261 getTextArea4Wed Mar 06 2019 14:29:59 GMT+0530 (India Standard Time)
script.js:258 failed
该代码永远无法正常工作,这意味着没有50秒的间隔...
任何帮助