0

我有一个功能,说

function runSomething()
{
   alert("hello");
}

我有window.onhashchange = runSomething;
并且在我的代码中,我打电话window.location.hash = "#processsection"

runSomething 运行,但是它在页面执行到#processsection 之前运行......我怎样才能让它只在我在#processsection 之后运行?

4

1 回答 1

0

在您的场景中,我可能会使用 if 条件来检查该 div 或 body(以适用者为准)是否正在播放动画。滚动。这是一个未经测试的粗略想法。

function runSomething() {        
    if ($('body').is(':animated') {
        $('body').queue(function() {
            alert("hello");
        });
    } else {
        alert("hello");
    }
}
于 2012-05-17T23:59:41.387 回答