lundi 13 mars 2017

Add class and change inner HTML when checkbox is checked

I want to add/remove a class to the upper div with class "related-box-check" and change the inner HTML of the label, when the checkbox is checked. It should be removed (back to default), when the box is unchecked again. My checkbox-id is generated dynamically.

How can I achieve that?

My HTML looks like this:

<div class="related-box-check">
<input type="checkbox" class="checkbox related-checkbox" id="related-checkbox162569" name="related_products[]" value="162569">
<label class="label-related" for="related-checkbox162569">Add for check</label>
</div>

JSFiddle: http://ift.tt/2mjAYfp




Aucun commentaire:

Enregistrer un commentaire