0

hi i am using jquery

i want to add css color with important property to a label

i am currently trying it by

 jQuery(this).css('color','green !important')

with out using a class

like

label_class
{
    background-color:#f2f2f2 !important;
}

and using like

jQuery(this).addClass('label_class');

can i use only jquery to do this , please help

Charles
  • 50,943
  • 13
  • 104
  • 142
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193
  • 1
    possible duplicate of [How to include !important in jquery](http://stackoverflow.com/questions/1986182/how-to-include-important-in-jquery) – Jeremy Aug 02 '12 at 08:08

2 Answers2

3

Yes its not that hard, but you should try avoid using !important all the time.

$("#tabs").css("cssText", "height: 650px !important;");

Heres a link to similar question How to include !important in jquery

Hope this helps :)

Community
  • 1
  • 1
Lemex
  • 3,772
  • 14
  • 53
  • 87
3

You should never need to do this. The !important flag indicates that the style should take precedence. With jQuery, you are applying the style inline to the element and therefore it already has the highest precedence.

Note that if you are using !important, you are probably doing something wrong. Consider restructuring your CSS selectors to ensure you don't need it.

Paul Fleming
  • 24,238
  • 8
  • 76
  • 113