检查图像不存在,然后隐藏div [英] check if image does NOT exist then hide a div
本文介绍了检查图像不存在,然后隐藏div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果div中有图片,则隐藏div。但如果图像确实存在,那么我需要保持div可见。
If there is an image in the div then hide the div. But if the image does exist then i need to keep the div visable.
但它不工作。这是我的代码:
But its not working. Here is my code:
HTML :
<table id="FeatureBox">
<tbody>
<tr>
<td>
<div id="productInfoGrid">
<div id="ProductIconsTitle">
<p>PRODUCT FEATURES</p>
</div><img width="563" height="337" src="http://www.preserveshop.co.uk/images/black-jam-jar-lid-58mm.jpg" alt="http://www.preserveshop.co.uk/images/black-jam-jar-lid-58mm.jpg" style="cursor: -moz-zoom-in"><div style="clear:both;"></div>
</div>
</td>
</tr>
</tbody>
JQUERY: / strong>
JQUERY:
if ($("#div#productInfoGrid:not(img)").length) {
$("#productInfoGrid").hide();
}
JSFIDDLE : http://jsfiddle.net/wJgpr/3/
推荐答案
$("div#productInfoGrid").has('img').hide();
Demo
$(#div#productInfoGrid:not(img))
应为 $(div#productInfoGrid:not(img))
这篇关于检查图像不存在,然后隐藏div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文