$("img").each(function() {
if($(this).is(':hidden')) {
$("p#nothing").show();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="imgWrap">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/326/800/9396326800_4_1_4.jpg" class="fashion black" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/323/401/9396323401_4_1_4.jpg" class="fashion" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/306/622/9396306622_4_1_4.jpg" class="fashion pink" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/361/707/5396361707_4_1_4.jpg" class="fashion brown" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/302/800/5396302800_4_1_4.jpg" class="fashion pink" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/377/800/5396377800_4_1_4.jpg" class="fashion black" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/349/725/5396349725_4_1_4.jpg" class="fashion beige" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5639/306/401/5639306401_4_1_4.jpg" class="jumpsuit blue" alt="">
</div>
$("img").each(function() {
if($(this).is(':hidden')) {
$("p#nothing").show();
}
});
HTML:
<div id="imgWrap">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/326/800/9396326800_4_1_4.jpg" class="fashion black" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/323/401/9396323401_4_1_4.jpg" class="fashion" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/9396/306/622/9396306622_4_1_4.jpg" class="fashion pink" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/361/707/5396361707_4_1_4.jpg" class="fashion brown" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/302/800/5396302800_4_1_4.jpg" class="fashion pink" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/377/800/5396377800_4_1_4.jpg" class="fashion black" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5396/349/725/5396349725_4_1_4.jpg" class="fashion beige" alt="">
<img src="http://static.pullandbear.net/2/photos/2012/V/0/1/p/5639/306/401/5639306401_4_1_4.jpg" class="jumpsuit blue" alt="">
</div>
<p id="nothing">No products were found that matched your filters</p>
这不起作用,但我真的不知道为什么。需要做什么:检查所有图像是否可见。如果它们都不可见,则显示一个段落。
谢谢。