Monday, March 30, 2009

[jQuery] Re: jQuery and !important

Hey Sebastian,

On Mar 30, 2009, at 4:49 PM, segarva wrote:

in my CSS file I have:


*{

background-color:#ffffff!important;

}


.destacado{

background-color:green!important;

}


and, in my jQuery code:


$("a").click(function(){

$("p:last").addClass("destacado");

}


and it's working fine! the last paragraph is converted to green using !

important and  addClass method.


Thanks, it is indeed a nicer solution to use classes, rather than directly setting CSS properties. However, in my case it's a special CSS setting per element, so I would have to define lots of classes in order to support many elements (i.e. it will be limited to the amount of classes I pre-define. In this case it will not really help.

Thanks for the suggestion anyways!

Regards,
-- 
Martijn.


No comments: