透明背景与jQuery?

时间:2011-07-01 13:06:49

标签: jquery

我使用jQuery fadeTo来获得DIV的透明背景,但这也会影响DIV中的文本内容。有没有办法只影响背景DIV而不影响内容?

2 个答案:

答案 0 :(得分:1)

您可以使用

$("div").animate({background: "transparent"}, 1000);

您需要Color Animation plugin才能获得该功能。

答案 1 :(得分:1)

或者您可以直接在http://www.bitstorm.org/jquery/color-animation/

下载该插件

要使用该插件,只需如下例所示:

$("#div").animate({backgroundColor: 'rgba(73, 47, 20, 0.6)'});

上面的样本rgba值将生成:红色值= 73,绿色值= 47,绿色值= 20,alpha值= 0.6,值越小,透明。