vendredi 31 octobre 2014

How to change the color of a div using jquery?


Vote count:

0




I have multiple items in my website having same class name here is my code for single item price section only



<tr>
<td><table cellspacing="0" cellpadding="0" width="100%"><tbody><tr><td><div class="prod-price"><span class="price-old" style="display: none;">9.90</span>
<span class="price-new">9.90</span></div>
<div style="font-size: 0.8em; padding-top: 4em; display: none;" class="save- sale">0.00</div>
<div class="pc"></div>
</td><td><div class="prod-price">
</div></td></tr><tr><td class="medtext">&nbsp;<b>(Out of Stock)</b></td></tr>
</tbody></table></td>
</tr>


What i need to do i want to change the color of only for that div(having class name price-new) which has (out of status) message.i tried the below code but it changes the color for all divs having class name price-new i want this script to be apply only for those items which is having out of stock message using either jquery or java script.


this is what i have tried



<script>
$(function () {
$(".medtext").each(function(){
if($.trim($(this).text()) == 'Out of Stock') {
$(".price-new").css("color","black");
}
});
});
</script>


asked 1 min ago







How to change the color of a div using jquery?

Aucun commentaire:

Enregistrer un commentaire