How to apply !important using .css()?

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

    May be it look's like this:

    Cache

    var node = $('.selector')[0];
    OR
    var node = document.querySelector('.selector');
    

    Set CSS

    node.style.setProperty('width', '100px', 'important');

    Remove CSS

    node.style.removeProperty('width');
    OR
    node.style.width = '';

提交回复
热议问题