我正在开发一个用户可以发布的应用程序。我想这样做,以便当帖子的 id 在 url 中散列时,帖子会闪烁。为此,这是我的代码:
function getHash() {
var hash = window.location.hash;
return hash;
}
if (getHash()) {
$(getHash()).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
}
现在,我知道如果我放一个alert('in the if statement');
,这段代码是 b/c 运行的,只要 url 中有一个哈希值,它就可以工作。我也知道这部分有效:
$(getHash()).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
因为如果我在控制台中运行它,帖子就会闪烁。出了什么问题不允许这个工作?