views:

11

answers:

2

Hi I'm trying to recreate the effect like on SO where you click a comment, 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

A: 

Is this what you're looking for?

$(document).ready(function(){
....
});
methodin
uh perhaps, how would i adjust ` $(theHash).hover(function() {` so that the callback is still triggerd?
Ross
Maybe I was unclear in what you're after. If you want a dynamic element on the page to appear a different color then fade out you would do that via AJAX. So fetch your new HTML section via AJAX, append it to the page, apply a background color to it then use the animate function to animate it back to white (or whatever background your page is)
methodin
A: 

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 !

Ross