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

1

2 Answers 2

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 :)

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.