How to apply !important using .css()?

后端 未结 30 2981
情深已故
情深已故 2020-11-21 07:06

I am having trouble applying a style that is !important. I’ve tried:

$(\"#elem\").css(\"width\", \"100px          


        
30条回答
  •  一生所求
    2020-11-21 07:28

    You can do this:

    $("#elem").css("cssText", "width: 100px !important;");
    

    Using "cssText" as the property name and whatever you want added to the CSS as its value.

提交回复
热议问题