Not sure why it doesn't work for you. Of course, I was using "#container" as an example. You would need to replace that with an actual ID of a containing element on your page. There's no reason it shouldn't work if you're identifying IDs and classes correctly.

You could also modify the style attribute directly, if all else fails...

$('#some_div').css('color', '#fff');


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On May 4, 2008, at 5:24 AM, rene.olivo wrote:


Makes lots of sense but still doesn't work, I'll take it into account
this next time I start a project. Thanks a lot.

On May 3, 11:57 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
In general, IDs take precedence over classes for CSS style rules. One
thing you could do is refer to a containing element's ID in the style
rule for the class. Something like this:

#container .new_class {
  color: #FFF;

}

hope that helps.

--Karl
_________________
Karl Swedbergwww.englishrules.comwww.learningjquery.com

On May 3, 2008, at 11:23 PM, rene.olivo wrote:



Hello, I have tried this code:

$('#some_div').addClass('new_class');

And it works really well, it adds the class to the element. The
problem is that if this element had previously had any style applied
to it like:

#some_div {
 color: #F00;
}

to change the color with the new class I'd have to use !important so
it can be applied like this:

.new_class {
 color: #FFF !important;
}

does anyone knows why this happen? it works great and everything but I
rather not use the important statement if possible.

thanks.

Reply via email to