jquery #hash automatic function onload
Hi I'm trying to recreate the effect like on SO where you click a comme开发者_如何学Pythonnt, and the page loads, and the given comments background fades out.
so far I have
var theHash = window.location.hash;
$(theHash).hover(function() {
$(this).stop().animate({ backgroundColor: "#a7bf51"}, 800);
},function() {
$(this).stop().animate({ backgroundColor: "#ffffff" }, 800);
});
which works fine on a hover, but i would like this to be done automatically when the page is ready.
is there an event for this, rather than using "hover"? thanks
think i was over complicating things, this works fine for me -
$(document).ready(function(){
var theHash = window.location.hash;
theHash=theHash.substr(1);
$("#f"+theHash).css('backgroundColor',"#E47527");
$("#f"+theHash).animate({backgroundColor: "#ffefe3" }, 2000);
});
thanks anyways !
Is this what you're looking for?
$(document).ready(function(){
....
});
精彩评论