$("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>
這並不工作,但我真的無法找出原因。需要做什麼:檢查所有圖像是否可見。如果它們都不可見,則顯示一段。
謝謝。
它應該工作,你可以發佈的HTML? – undefined 2012-07-09 17:23:13
@undefined:添加了HTML。 – 2012-07-09 17:50:09
您的HTML沒有任何隱藏圖像。 – j08691 2012-07-09 19:29:41