Jason4Ever
Jason4Ever

Reputation: 1479

how to animate remove background after hover?

i want the right way to remove background after setting it when mouse over an element,

i tried these :

$("#store_header .right #nav ul li").hover(function() {
    $(this).animate({backgroundColor : '#0097d5'}, 200);}
    ,function() {
        $(this).animate({backgroundColor : ''}, 200);
    }

);

but second function didn't work , so please tell me what's the error and what's the right

Upvotes: 1

Views: 562

Answers (2)

nbrooks
nbrooks

Reputation: 18233

Demo

$("#store_header .right #nav ul li").hover(
    function() {
        $(this).animate({backgroundColor : '#0097d5'}, 200);
    }, function() {
        $(this).animate({backgroundColor : 'transparent'}, 200);
    }
);

Upvotes: 2

xdazz
xdazz

Reputation: 160883

You need to set a color to revert , check the working demo. (note: included jquery-ui)

$("#store_header .right #nav ul li").hover(function() {
    $(this).animate({backgroundColor : '#0097d5'}, 200);
    } ,function() {
        $(this).animate({backgroundColor : '#fff'}, 200);
    }
);

Upvotes: 2

Related Questions