$("#PtmIframe").contents().find("#header .sf-menu > li.sfHover > a, #header .sf-menu > li > a:hover, #header .sf-menu > li.sfHoverForce > a").css('background',"#"+HIhovcolor.!importanted).addClass("active");
localStorage.setItem("HIhovcolor", HIhovcolor);
Asked
Active
Viewed 106 times
0

Raging Bull
- 18,593
- 13
- 50
- 55
-
possible duplicate of [How to include !important in jquery](http://stackoverflow.com/questions/1986182/how-to-include-important-in-jquery) – Satpal May 03 '14 at 10:30
4 Answers
2
General Syntax
jQuery.style(name, value, priority);
so use
$("#tabs").style('background', "#"+HIhovcolor, 'important');

Sajad Karuthedath
- 14,987
- 4
- 32
- 49
-
1
-
1@Satpal above link i provided may help you and i have also seen this type of an answer here too http://stackoverflow.com/a/8894528/2967572 – Sajad Karuthedath May 03 '14 at 10:28
1
i think this will help you
$("#tabs").css("cssText", "height: 650px !important;");

Gaurang s
- 831
- 6
- 18
0
$("#PtmIframe").contents().find("#header .sf-menu > li.sfHover > a, #header .sf-menu > li > a:hover, #header .sf-menu > li.sfHoverForce > a").css('background',"#"+HIhovcolor.+" !importanted").addClass("active");
localStorage.setItem("HIhovcolor", HIhovcolor);

Gaurang s
- 831
- 6
- 18
-
1Why two different answers? Can't you write both of them in one answer itself? – Raging Bull May 03 '14 at 10:09
-
0
As i see you don't need to have a !important
css hack with jQuery's .css()
method, this method adds an inline style to the dom node you target.
!important
should be used in .css
files to a specific css class where you want it to override the styling.
Your case:
$("#PtmIframe").contents().find("#header .sf-menu > li.sfHover > a, #header .sf-menu > li > a:hover, #header .sf-menu > li.sfHoverForce > a")
.css('background',"#"+HIhovcolor)
.addClass("active");
This line .css('background',"#"+HIhovcolor)
would output something like this:
<li style='backgroung: #yourColorCode' class='active'>.....</li>
So i have to say that inline styling have much priority than the css class styling, then you should not have any issues with this. Yet you can do this:
.css('background', '#' + HIhovcolor + ' !important')
//---------------------------------^^^^^^^^^^^^^^^---concatenate it as string.

Jai
- 74,255
- 12
- 74
- 103