How to apply !important using .css()?

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

    I also discovered that certain elements or add-on's (like Bootstrap) have some special class cases where they do not play well with !important or other work-arounds like .addClass/.removeClass, and thus you have to to toggle them on/off.

    For example, if you use something like

    the only way to successfully modify elements like colors of rows is to toggle the table-hover class on/off, like this

    $(your_element).closest("table").toggleClass("table-hover");

    Hopefully this work-around will be helpful to someone! :)

    提交回复
    热议问题