I'm developing a coffee shop product website. We have an area where each product has a coffee strength indicator. The database produces a value depending on whether the strength is Strong, Medium, Weak or n/a. The n/a is for non-coffee products.
If n/a is displayed I would like to hide the containing div.
The code I have so far is below. I have some JavaScript that replaces the text displayed by the database with an image for the strength indicator.
If the coffee-strength in the span tag is n/a I would like to hide .
Is this possible???
Thanks in advance.
<div class="coffee-strength">
<p>Coffee Strength: <span><?php echo $_product->getAttributeText('coffeestrength'); ?></span></p>
</div>
<script type="text/javascript">
jQuery(function ($) {
$('.coffee-strength p span').each(function () {
var string = $.trim($(this).text());
$(this).html('<img src="/images/' + string + '.png" alt="' + string + '" />');
});
});
</script>