I'm working on an element that I need to be able to add '!important' to my inline style that I am dynamically creating using JS in order to override several CSS styles that exist in stylesheets developed by another person. Unfortunately, these stylesheets are used globally and this particular area has a slew of '!important's strung about through it that I cannot modify without risking altering previous headers that exist throughout the site. I'm fairly rough in my JS skills, thus am having a rough go of figure this out.
Here is my current code snippet:
fixTextPosition: function()
{
var width = $( window ).width();
if (width > 1451){
width = 1451;
}
var height = $( window ).height();
if (height > 816){
height = 816;
}
$("#banner-resize").css("minheight", height);
if (height < 816){
$("#banner-resize").css("minHeight", height - 1);
}
}
I am attempting to append "!important" to the "minHeight" value after it has gone through (height - 1) and cannot seem to figure out how to add the value as a string.
Thank you in advance to any helpers!
Edited After Answers
Thanks to all who gave some thoughts - I'll take what I learned from posting my question in here to make sure my next question is better phrased and given with more context. :)
The above question is referring to a global header element that has several "min-height = x!important" existing in global stylesheets that a previous developer created - meaning I don't get to play as freely as I would like. I was able to work around it by creating a new class that contains all of the previous positioning styles and the new "min-height=x" sans '!important' which allowed me to use the above JS as desired.
I'm still curious to see if there is a more simple JS workaround to append an '!important' to an inline style as I don't really want to be creating new classes every time I run into this particular situation.