user790843
user790843

Reputation: 133

Transparent background with jQuery?

I use jQuery fadeTo to get a transparent background of a DIV, but this also affects the content inside the DIV like text. Is there a way to only affect the background DIV and not the content?

Upvotes: 1

Views: 259

Answers (2)

Akbar Kautsar
Akbar Kautsar

Reputation: 418

Or you can directly download the plugin at http://www.bitstorm.org/jquery/color-animation/

To use the plugin simply as example below:

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

The sample rgba value above will generate: red value = 73, green value = 47, green value = 20, and alpha value = 0.6, the less the value, the transparent.

Upvotes: 1

Gal
Gal

Reputation: 23662

You can use

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

You'll need the Color Animation plugin for that capability.

Upvotes: 1

Related Questions