Reputation: 130
I try to change html element, on php if statement, I tried this:
<?if ($item['DISCOUNT_PRICE']<$item['PRICE'] AND $item['DISCOUNT_PRICE']>0):?>
<?//MM-227?>
<div class="catalog-product__old-price-outer">
<?=price($item['PRICE'], $item['CURRENCY'])?>
</div>
<?//MM-227?>
<script>
$(".inner-price-block .price-offer").css("color","red");
</script>
<?endif;?>
<div class="inner-price-block">
<div id="sku_price_<?=$item['ID']?>" class="price-offer">
<?=price($item['DISCOUNT_PRICE'], $item['CURRENCY']);?>
</div>
</div>
I try to change class price-offer, with this script:
<script>
$(".inner-price-block .price-offer").css("color","red");
</script>
what I missed?
Upvotes: 0
Views: 57
Reputation: 2525
Try this :
<script>
$(document).ready(function() {
$(".inner-price-block .price-offer").css("color","red");
});
</script>
Upvotes: 1
Reputation: 1864
You can use php
instead of jquery to put condition like below:
<?php $color="";
if ($item['DISCOUNT_PRICE']<$item['PRICE'] AND $item['DISCOUNT_PRICE']>0):
$color="red";?>
<?//MM-227?>
<div class="catalog-product__old-price-outer">
<?=price($item['PRICE'], $item['CURRENCY'])?>
</div>
<?php endif;?>
<div class="inner-price-block">
<div id="sku_price_<?=$item['ID']?>" class="price-offer" <?= ($color!=''?'style="color:'.$color.'":""'?>>
<?=price($item['DISCOUNT_PRICE'], $item['CURRENCY']);?>
</div>
</div>
Upvotes: 0