Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find out if css of layer is block jquery

I'm trying to figure a way of finding out if a layer is displayed or not

if ($('.property > .evenprop').css('display','block')){
    $('.otherprop').show();
    }
    else {
    $('.otherprop').hide();
    }

So something like if this is true

<div class="property">

<div class="evenprop" style="display:block">blah</div>

</div>

Then show this layer

<div class="otherprop">blahblah</div>

$('.otherprop').show();

Else if this is true

<div class="property">

<div class="evenprop" style="display:none">blah</div>

</div>

Then hide this layer

<div class="otherprop">blahblah</div>

$('.otherprop').hide();

Can't seem to get this to work though any ideas?

Thanks

Jamie

like image 669
Jamie Taylor Avatar asked Nov 19 '25 21:11

Jamie Taylor


1 Answers

You're looking for the :visible pseudo-class.

if ($('.property > .evenprop').is(':visible')){
    $('.otherprop').show();
} else {
    $('.otherprop').hide();
}

The above can be reduced to

$('.otherprop').toggle($('.property > .evenprop').is(':visible'));
like image 155
David Hedlund Avatar answered Nov 22 '25 10:11

David Hedlund



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!