tags:

views:

120

answers:

4

I have an application which is spitting out: body {background: #FFF;}

over and over again. I am unable to fix the bug in the application. How can I use jquery to remove body {background: #FFF;} each time it occurs?

A: 

Where does this occur? Is it in the -section of the page you use jquery in or does it appear in an extra css-file?

ApoY2k
@ApoY2k - Just as a note, questions/clarification requests about the original question should be added as a comment to the original question instead of an actual answer ;-)
Topher Fangio
+2  A: 

You can't edit the css (I assume) but can you set an inline style on the body? This will overwrite the CSS applied style.

If not, here is the jQuery call to remove it on page load:

$(document).load(
    function()
    {
        $("body").css( "background-color", "transparent" );
    }
);
Kevin Peno
A: 

It sounds like you're wanting to edit an style block declaration? I'm not sure jQuery really does much to help you in that case, but something like this might work:

for(int i=0;i<document.styleSheets.length;i++) {
  var sheet = document.styleSheets[i],
      rules = sheet.cssRules ? sheet.cssRules : sheet.rules;
  for(int j=0;j<rules.length;j++) {
    if(rules[j].toLower() == 'body {background: #fff;}')
      rules[j] = 'body {}';
  }
}

You might check here for more.

Brother Erryn
A: 

there are multiple instances of this on the page that are overwriting anything I put in the css.

Perhaps you are looking at it the wrong way... It can be overridden in the CSS, try putting this in the CSS file:

body{
   background:#0000ff !important;
}

Note the "!important" bit...

pǝlɐɥʞ