2

我正在尝试设置我的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>";
}

seriesIdOnBluronBlur为带有 id 的输入调用series_id

我在做什么错setTimeout

4

1 回答 1

8

您正在调用该函数并将结果传递给setTimeout. 您想将函数传递给setTimeout

setTimeout(seriesIdOnBlur2, 3000);
于 2013-08-08T00:03:18.507 回答