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:
$("div#productInfoGrid").has('img').hide();
Demo
$("#div#productInfoGrid:not(img)")
should be $("div#productInfoGrid:not(img)")
if ( !$("#productInfoGrid").has("img") ) {
$(this).hide();
}
or simpler
$("#productInfoGrid").not(':has("img")').hide();
DEMO
You can use .find() (Reference: http://api.jquery.com/find/)
if ($("#productInfoGrid").find('img').length == 0) {
$("#productInfoGrid").hide();
}
if ($("#productInfoGrid img").length == 0) {
$("#productInfoGrid").hide();
}