Logic may break somewhere in jquery discoun
<p>This is the example - but the problem is that it stops at the product which does not have sale price, say "I Love London Mini Frame Purse" for $135. It will continue to find class item but will stop at the product which has only one actual price (no sale price). Why is that? Can't it continue finding class item and calculate accordingly till the end of the page ignoring the products with actual price only?</p>

<pre><code>function calculate(sale, original) {

    percentDiscount = Math.round(eval((sale / original) * 100));

    return percentDiscount;
}

$(document).ready(function() {

    var salecost;
    var originalcost;
    var percent;
    $('.item').each(function() {
        salecost = $(this).find('.saleprice').html();
        salecost = salecost.replace(/[^\d\.]/g, "");


        originalcost = $(this).find('.actualprice').html();
        originalcost = originalcost.replace(/[^\d\.]/g, "");
        percentDiscount = calculate(salecost, originalcost);
        if (percentDiscount &gt; 30) {

            $(this).find("#percentoff").html((percentDiscount) + '%');
            $(this).find("#percentoff").addClass('badge30');
        }

        if (percentDiscount &gt; 50) {

            $(this).find("#percentoff").html((percentDiscount) + '%');
            $(this).find("#percentoff").addClass('badge50');
        }

        if (percentDiscount &gt; 70) {

            $(this).find("#percentoff").html((percentDiscount) + '%');
            $(this).find("#percentoff").addClass('badge70');
        }
    });
});
</code></pre>

<p><strong>Edit</strong>
One question
if 0 and 30 = green color
if 30 and 50 = brown color
if 50 and 70 = yellow color
if 70 and 100 = red color</p>

<p>would it be this:</p>

<pre><code> if (50&gt; percentDiscount &gt; 70) {

                    $(this).find("#percentoff").html((percentDiscount) + '%');
                    $(this).find("#percentoff").addClass('badge70');
                }
</code></pre>

<p><strong>EDIT II</strong>
ANother question: </p>

<p>how to have price in html to be appended to div percentoff? </p>

<pre><code>$(this).find("#percentoff").append.html((percentDiscount) + '%');
</code></pre>
