Can I use jquery to remove/negate css !important rule?

后端 未结 5 1391
挽巷
挽巷 2020-12-16 12:07

If there is a CSS rule that uses !important, is there a way to remove the !important rule so that I can make further downstream style changes with

5条回答
  •  -上瘾入骨i
    2020-12-16 12:26

    You need to create a new class to apply fade.

    CSS:

    div.stubborn { display: none !important; }
    div.stubborn.fade-ready { display: block !important; opacity: 0; }
    

    JS:

    $('.stubborn').addClass('fade-ready').animate({opacity: 1}); //to show
    $('.stubborn').fadeOut(function() {$(this).removeClass('fade-ready');}); //to hide
    

    DEMO HERE

提交回复
热议问题