开发者

Jquery: hide div that has no visible divs inside

开发者 https://www.devze.com 2023-02-12 18:48 出处:网络
I have the fallowing markup: <div class=\"container\"> <div style=\"display:none\">1</div>

I have the fallowing markup:

<div class="container">
    <div style="display:none">1</div>
    <div style="display:none">2</div>
    <div style="display:none">3</div>
</div>
<div class="container">
    <div style="display:none">1</div>
    <div>2</div>
    <div style="display:none">3</div>
</div>
<div class="container">
    <div>1</div>
    <div>2</div>
    <div style="display:none">3</div>
</div>

<div class="container">
    <div style="display:none">1</div>
    <div style="display:none">2</div>
    <div style="display:none">3</div>
    <div style="display:none">4</div>
</div>

How do I hide all the divs with class 'container' that have only hidden divs inside us开发者_C百科ing jQuery selectors? In given case this would be 1st and 4th ones.

$(document).ready(function() {
    // how to hide all the divs with class 'container' that have no visible divs inside?
});

See markup at jsfiddle: http://jsfiddle.net/tfY58/

Thanks!


Like this:

$('.container:not(:has(:visible))')
0

精彩评论

暂无评论...
验证码 换一张
取 消