jquery #hash自动函数onload

时间:2010-09-30 15:29:19

标签: jquery onload-event

您好我正在尝试重新创建效果,例如在您单击注释的情况下,页面加载,并且给定的注释背景淡出。

到目前为止我已经

    var theHash = window.location.hash;
    $(theHash).hover(function() {
    $(this).stop().animate({ backgroundColor: "#a7bf51"}, 800);
    },function() {
    $(this).stop().animate({ backgroundColor: "#ffffff" }, 800);
    });

在悬停时效果很好,但我希望在页面准备好后自动完成。

有没有这样的事件,而不是使用“悬停”? 感谢

2 个答案:

答案 0 :(得分:2)

认为我过度复杂化了,这对我来说很好 -

$(document).ready(function(){
    var theHash = window.location.hash;
    theHash=theHash.substr(1);  
    $("#f"+theHash).css('backgroundColor',"#E47527");
    $("#f"+theHash).animate({backgroundColor: "#ffefe3" }, 2000);
});

非常感谢!

答案 1 :(得分:0)

这是你要找的吗?

$(document).ready(function(){
....
});
相关问题