I am struggling with adding a class to a specific div only if it contains an image.
<div class="large-6 columns check-Div">
<div class="custom-table">
<div class="text">
<?php echo $latestimage; ?>
</div>
<div class="custom-table-box">
<?php echo $table; ?>
</div>
</div><!-- end custom-table -->
</div>
if ($j(".large-6.columns.check-Div > .custom-table-box:contains('size-full')")) {
$j('.large-6.columns.check-Div').addClass("hasImage");
}
The jQuery code above is currently adding the hasImage
class to all divs, but I want this class to be added only when the div actually contains an image. Is there a way to achieve this for individual instances or by parent element? Any guidance would be greatly appreciated!