if the image contains NO src then i want to hide the div.PageHeaderDescription
<div class="PageHeaderDescription">
<h1>Bistro 300</h1>
<img border="0" src="images/Category/large/469.jpg" id="EntityPic621">
This is some text
</div>
To do this i used:
if ($("div.PageHeaderDescription img").filter("[src='']")) {
$("div.PageHeaderDescription").hide();
}
however if you put a src path into the image the jquery still hides div.PageHeaderDescription which is wrong. It needs to be visable if there is an image src.
Here is my example: http://jsfiddle.net/dfasd/1/
filter()returns a jQuery object, which is always truthy, whether or not elements were matched.What you should be doing instead is checking the
lengthproperty of the object returned;Although you could shorten this to;
But if you have multiple
div.PageHeaderDescriptionon the page, you should be doing;