admin管理员组文章数量:1022670
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
2 Answers
Reset to default 3Yes 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.
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
2 Answers
Reset to default 3Yes 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.
本文标签: javascriptcan i add css with importantonly using jqueryStack Overflow
版权声明:本文标题:javascript - can i add css with !important , only using jquery - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745496988a2153210.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论