Alternative to css3 not selector

Posted by Raynos on Stack Overflow See other posts from Stack Overflow or by Raynos
Published on 2011-01-10T14:28:00Z Indexed on 2011/01/10 14:54 UTC
Read the original article Hit count: 119

Filed under:
|
|
|

Are there any alternatives to the :not css3 selector that are compliant with IE8 (and quirks mode).

Either in css or javascript/jquery that emulates the selector or something similar.

I am using *:not as follows below. Feel free to recommend a solution that avoids the use of :not completely.

@media screen {
    #printable {
        visibility: hidden;
    }
}

@media print {
    *:not(#printable) {
        visibility: hidden;
    }
    #printable {
        position: absolute;
        visibility: visible;
    }
}

Note that the use of :not is tied to the use of @media print so just using a simple jQuery solution to apply css to $(":not(#printable)") won't work without being clever.

Including an entire library like ie9.js or selectivirz isn't an option as it can effect various other parts of the pages and would involve a large section of re-testing.

a jsfiddle that shows it working in browsers that support :not http://jsfiddle.net/Raynos/TjKbz/

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery