开发者

Jquery: hide div that has no visible divs inside

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜