jQuery addClass example
Change class name on click in jQuery
HTML
<form>
<fieldset id="extras">
<legend>Select Extras</legend>
<label><input type="checkbox" value="candles">Candles</label><br>
<label><input type="checkbox" value="inscription">Inscription</label><br>
<label><input type="checkbox" value="decoration">Decoration</label><br>
<label><input type="checkbox" value="special">Special Frosting & Icing</label>
</fieldset>
<input type="text" id="total" value="0">
<input type="submit" value="Submit">
</form>
JavaScript
$('#extras input').on('click', function() {
$('#total').val($('#extras input:checked').length);
});