JSFiddle - React, Tailwind, and code Playground
by Alex Azuero
HTML
<div id="dermal">
<p><input type="checkbox" value="Crows feet" rel="15">Crows feet</p>
<p><input type="checkbox" value="Frown lines" rel="15">Frown lines</p>
<p><input type="checkbox" value="Individual facial line" rel="15">Individual facial line</p>
</div>
<div id="wrinkle">
<p><input type="checkbox" value="Wrinkle1" rel="30">Crows feet</p>
<p><input type="checkbox" value="Wrinkle2" rel="15">Frown lines</p>
</div>
<span id="output"></span>
JavaScript
$(document).ready(function() {
function recalculate() {
var sum = 0;
$("input[type=checkbox]:checked").each(function() {
sum += parseInt($(this).attr("rel"));
});
$("#output").html(sum);
}
$("input[type=checkbox]").change(function() {
recalculate();
});
});