This works as it should except if you click on the same label many times fast it breaks the toggle(). I expect this behavior as toggle() working as it should. The question is: How do I make it so that the toggle() doesn’t run if the element is already :checked?
$(document).ready(function() {
$("#UPLOADMYDESIGNFF").show();
$('label').click(function() {
var total = 0;
$('.option:checked').each(function() {
if( $(this).is('#DESIGNONLYFF:checked, #NOPRINTFF:checked'))
{
$("#UPLOADMYDESIGNFF").toggle();
}
total += parseFloat($(this).data('number'));
$(this).parent().addClass('cust-selected-cart-item');
});
$('.option:not(:checked)').each(function() {
$(this).parent().removeClass('cust-selected-cart-item');
});
$('.sub-total-t').html('$' + total.toFixed(2) );
});
});
Of coarse the default for DIV:UPLOADMYDESIGNFF is set to DISPLAY:NONE
HTML
<label><input id="NOPRINTFF" type="radio" name="print"/></label>
<label><input id="DESIGNONLYFF" type="radio" name="print"/></label>
Nevermind all – I figured out the problem.. just changed
(this)to.option:checkednow it works right. Thanks anyway! 🙂