我正在尝试设置我的onblur
所以它显示加载条3秒......但是代码似乎只是错过了它并直接进入第二个函数...
function seriesIdOnBlur()
{
document.getElementById("series_id_check").innerHTML = "<img src='http://www.webscriptlab.com/file/loading/output/13759195689.gif' /> ";
setTimeout(seriesIdOnBlur2(), 3000);
}
function seriesIdOnBlur2()
{
var id = document.getElementById("series_id").value;
var message = "";
if (series[id] === undefined)
{
message = "The Series ID you input was invalid";
}
else
{
var seriesId = series[id];
var game = seriesId['game'];
var name = seriesId['name'];
message = "ID: " + id + " is for the " + name + " series playing " + game + ".";
}
document.getElementById("series_id_check").innerHTML = "<span>" + message + "</span>";
}
对于ID为seriesIdOnBlur
的输入, onBlur
被称为series_id
。
我对setTimeout
做错了什么?
答案 0 :(得分:8)
您正在调用该函数并将结果传递给setTimeout
。您希望将该函数传递给setTimeout
:
setTimeout(seriesIdOnBlur2, 3000);