How to apply !important using .css()?

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

    After reading other answers and experimenting, this is what works for me:

    $(".selector")[0].style.setProperty( 'style', 'value', 'important' );
    

    This doesn't work in IE 8 and under, though.

提交回复
热议问题