How to get the value of a radio buttons ID on click.
<script>
$(document).ready(function() {
$('label').click(function() {
var total = 0;
$('.option:checked').each(function() {
total += parseInt($(this).val());
});
$('.sub-total-t').html('$' + total);
});
});
</script>
This script works for value –> How do I assign the ID instead?
<label><input type="radio" name="print" class="option" id="25" value="p10"/> Starter 500 </label>
Try to do this:
But it’s better to use the
dataattribute to store this kind of values:And to retrieve it in javascript use this:
For
numberyou can use every name you want.