I need you not to give me back NaN. In div.calculado
I must put the% of each comparison (percentage discounted). There is no problem when it is a single operation, then what I need is that it is cyclical (the first price_sale is compared with the first price_compare, in the next div.element the same thing happens) I will appreciate your help, I hope to have been clear.
$(document).ready(function(){
$ve = $('.price_sale').text().split('S/. ').join('');
$nor = $('.price_compare').text().split('S/. ').join('');
$porc = $nor-$ve;
$pare = $porc/($nor/100);
$('.calculado').text($pare + '% DESCUENTO');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="element">
PRIMERA COMPARACION
<div class="price_sale">S/. 99.90</div>
<div class="price_compare">S/. 200.00</div>
PRIMER RESULTADO
<div class="calculado"></div>
</div><br/>
<div class="element">
SEGUNDA COMPARACION
<div class="price_sale">S/. 99.90</div>
<div class="price_compare">S/. 200.00</div>
SEGUNDO RESULTADO
<div class="calculado"></div>
</div><br/>
<div class="element">
TERCERA COMPARACION
<div class="price_sale">S/. 99.90</div>
<div class="price_compare">S/. 200.00</div>
TERCER RESULTADO
<div class="calculado"></div>
</div>