2012-09-02 106 views
1

我想設置它,當鼠標放在一個元素,如何在懸停後動畫移除背景?

我試過之後以正確的方式來去除背景這些:

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

); 

但第二個功能沒有工作,所以請告訴我有什麼錯誤,什麼是正確的

回答

2

您需要設置一個色彩還原,檢查the working demo。 (注:包括jQuery的UI)

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

Demo

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

+1'transparent'工作,但'none'不起作用。 – undefined