我尝试更改 html 元素,在 php if 语句上,我尝试了以下操作:
<?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>
我尝试使用以下脚本更改类(class)价格:
<script>
$(".inner-price-block .price-offer").css("color","red");
</script>
我错过了什么?
最佳答案
试试这个:
<script>
$(document).ready(function() {
$(".inner-price-block .price-offer").css("color","red");
});
</script>
关于javascript - jquery更改php if语句上的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32455461/