javascript - can i add css with !important , only using jquery - Stack Overflow

hi i am using jquery i want to add css color with important property to a label i am currently trying i

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

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

Share Improve this question edited Aug 2, 2012 at 8:15 Charles 51.5k13 gold badges106 silver badges144 bronze badges asked Aug 2, 2012 at 7:56 Kanishka PanamaldeniyaKanishka Panamaldeniya 17.6k31 gold badges127 silver badges195 bronze badges 1
  • 1 possible duplicate of How to include !important in jquery – Trump Voters Deserve Damnation Commented Aug 2, 2012 at 8:08
Add a ment  | 

2 Answers 2

Reset to default 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 :)

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745496989a4630234.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信