Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  194] [ 4]  / answers: 1 / hits: 32021  / 12 Years ago, thu, august 9, 2012, 12:00:00

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 JS or jQuery?



theirs.css



div.stubborn { display: none !important; }


mine.js



$('.stubborn').fadeIn();  // won't work because of !important flag


Unfortunately, I do not have control over the style applying the !important rule so I need a work-around.


More From » jquery

 Answers
66

Unfortunately, you cannot override !important without using !important as inline/internal style below the included theirs.css.



You can define a !important style and add it to .stubborn then adjust the opacity.. See below,



CSS:



div.hidden_block_el { 
display: block !important;
opacity: 0;
}


JS:



$('.stubborn')
.addClass('hidden_block_el')
.animate({opacity: 1});


DEMO: http://jsfiddle.net/jjWJT/1/



Alternate approach (inline),



$('.stubborn')
.attr('style', 'display: block !important; opacity: 0;')
.animate({opacity: 1});


DEMO: http://jsfiddle.net/jjWJT/


[#83728] Wednesday, August 8, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jarod

Total Points: 62
Total Questions: 111
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
jarod questions
;