Have you already considered toggling those classes?

$('#some_div').toggleClass('new_class').toggleClass('defaultClass');
Maybe you'll have to rewrite the 'new_class' properties to keep some
persistent styles.

On 4 maio, 11:37, Liam Byrne <[EMAIL PROTECTED]> wrote:
> An explicit "by id" style setting will always override a class-level
> style setting unless you use !important.
>
> Any way that you could have the some_div as a class instead of an ID ?
> That way the most recent applied class will override the initial setting.
>
> Liam
>
> 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