I am facing an issue with my div structure
<div class="block_content">
<img src="image1.png">
</div>
<div class="block_content">
<img src="image2.png">
</div>
<div class="block_content">
<img src="image3.png">
</div>
My goal is to hide image2 and image3, and I attempted to do so with the following code:
$(document).ready(function ($){
$('div.block_content').each(function()
{
if($("div.block_content:eq(1)").find('img').length)
{
$("div.block_content:eq(1)").addClass('hide-for-small');
}
if($("div.block_content:eq(2)").find('img').length)
{
$("div.block_content:eq(2)").addClass('hide-for-small');
}
});
});
Unfortunately, the above jquery code does not have the desired effect. It seems that I need to inspect each div individually because sometimes they may contain text only. In summary, if a div contains text, then show all three divs, otherwise hide the last two divs.
I would greatly appreciate any assistance or suggestions. Thank you in advance.