0

I have css on my page's body and I would like to overwrite overflow: visible !important;. I have tried the jQuery script below, but that doesn't do it"

 jQuery("body, #s4-workspace").css("overflow", "hidden !important");

CSS:

body, #s4-workspace {
    overflow: visible !important;
}

body {
    height: 100%;
    overflow: hidden; //overriden
    width: 100%;
}

I know there are two overflow already, but sadly I don't have the hand on that, otherwise it would be too easy, wouldn't it?

1
  • or is there a way to just remove overflow: visible !important; Commented Jun 28, 2011 at 12:52

3 Answers 3

1

As mentioned, ! important is not handled well by jQuery's css().

Here is a hack that will work if you don't mind overwriting the inline style attribute value (if it exists):

 jQuery("body, #s4-workspace")
     .attr("style", "overflow:hidden !important");

Like I said, it's a hack - but give it a try.

Demo: http://jsfiddle.net/dGbaD/

Sign up to request clarification or add additional context in comments.

2 Comments

or is there a way to just remove overflow: visible !important;
I don't think you can just "remove" it, it must be set to another value. Check the demo and see if that helps, I revised the errors in my previous answer.
1

AFAIK jQuery does not understand the !important part.

Try creating a class, like this:

.newClass {
   overflow: hidden !important;
}

And then set the class like this:

jQuery("body, #s4-workspace").addClass('newClass');

2 Comments

or is there a way to just remove overflow: visible !important;
you could remove it if it was set in a class
0

jQuery can't manage !important rules.

See:

How to apply !important using .css()?

http://hungred.com/how-to/jquery-javascript-css-important/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.