$(document).ready(function() {
    $("ul.gallery li").hover(function() { //On hover...
        var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
        //Set a background image(thumbOver) on the &lt;a&gt; tag
        var link = $(this).find("a.thumb");
        link.css({
            'background' : 'url(' + thumbOver + ') no-repeat center bottom'
        });
        //Fade the image to 0
        $(this).find("span").stop().fadeTo('fast', 0 , function() {
            $(this).hide() //Hide the image after fade
        });
    } , function() { //on hover out...
        //Fade the image to 1
        var link = $(this).find("a.thumb");
        $(this).find("span").stop().fadeTo('fast', 1,function(){
            link.css({
                'background' : 'none'
            });
        }).show();
   
    });
});
