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);
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 Answers4

2

General Syntax

jQuery.style(name, value, priority);

so use

$("#tabs").style('background', "#"+HIhovcolor, 'important');

adding-css-rules-with-important-using-jquery

Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49
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
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