Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide which have calc css?

Tags:

jquery

I wanted to hide the element which have calc css3:

nav{width: calc(100% - 20px); height: 50%;}

I tried this:

 $('*').filter(function() {
     return $(this).css('width') == 'calc';
 }).css("display","none");

But seems wrong way to do?

demo

like image 574
Bhojendra Rauniyar Avatar asked Jan 22 '26 01:01

Bhojendra Rauniyar


1 Answers

css method returns the computed value of the properties, you should read and filter the initial CSS rules:

var s = document.styleSheets[1], // the second stylesheet (for jsfiddle)
    rules = s.cssRules,
    selector = [],
    l = rules.length;

for ( var i = 0; i < l; i++ ) {
    if ( rules[i].style['width'].indexOf('calc') > -1 ) {
        selector.push( rules[i].selectorText );
    }
}

$( selector.join() ).hide(); 

http://jsfiddle.net/webozine/9EZ3k/

like image 101
undefined Avatar answered Jan 24 '26 19:01

undefined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!