tags:

views:

2327

answers:

3

If I set a CSS value on a specific element using:

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

I want to be able to unset that element-specific value and use the cascaded value, along the lines of:

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

But that syntax doesn't seem to work -- is this possible using another syntax?

Thanks in advance!

Edit: The value isn't inherited from the parent element -- the original values comes from an element-level selector. Sorry for any confusion!

+2  A: 

Try this:

$('#element').css('background-color', 'inherit');
HectorMac
Inherit is unfortunately not the behavior I'm looking for: "the property takes the same computed value as the property for the element's parent" from http://www.w3.org/TR/CSS2/cascade.html
cdleary
+2  A: 

Actually, the syntax I thought was incorrect (with null) seems to be working -- my selector was just improperly formed, and thus yielding no elements. D'oh!

cdleary
A: 

I think you can also do:

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

That's what I used to do a long time ago for the display property in plain-old-javascript to show/hide a field.

FryGuy