2009-11-21 60 views

回答

9

這個怎麼樣?

$('#element').css({'background-color':'transparent'}); 

您也可以嘗試

$('#element').css("background-color", "transparent"); 
1

您應該使用transparent代替none

2

這樣做:

$('#element').css('background-color','transparent'); 

$('#element').css({ backgroundColor: 'transparent' }); 
48

,您可以使用這兩個選項之一(我建議第二一個):

選項1:

$('#element').css('background-color','transparent'); 

選項2:

$('#element').css('background-color','inherit'); 
+3

是什麼選項之間的區別1和2 – hop 2012-06-13 13:35:48

+0

謝謝,這有助於: – Kirk 2012-07-10 21:55:08

+0

繼承:如果其父項爲紅色,則該元素也將爲紅色,如果父項是透明的,則該元素也將是透明的。並且在「透明」模式下,該元素沒有任何背景顏色並顯示父級顯示的內容。 – cubny 2012-11-13 12:22:59

0

試試這個:

$('#element').css('background-color', ''); 
+0

這似乎並不奏效。但設置爲''作品 – Vicer 2013-11-04 07:22:31

5

試試這個:

$('#element').css('background-color',''); 
0
$('.divclass') 
    .on("mouseenter", function() { 
     $(this).css({ 
      "background-color": "transparent" 
     }); 
    }) 
    .on("mouseleave", function() { 
     $(this).css({ 
      "background-color": "#000000" 
     }); 
    }); 
+0

它不工作...請建議另一件事 – 2016-06-24 06:46:09