How to apply !important using .css()?

后端 未结 30 2985
情深已故
情深已故 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:42

    You can achieve this in two ways:

    $("#elem").prop("style", "width: 100px !important"); // this is not supported in chrome
    $("#elem").attr("style", "width: 100px !important");
    

提交回复
热议问题