mercredi 3 juin 2020

How to make a function in Vanilla JS that puts checked attribute to the radio inputs before the selected input?

I can't find solution for this one.

Need to put attribute checked on the inputs that are before the selected input with JavaScript and the inputs after it unchecked.

UPD: changed the input type to the "checkbox" and now I need a function that marks "checked" the checkboxes before the last checked one, while unchecking succeeding boxes in case they were checked before.

Note: The solution has to use ES5 compatible syntax.

With code examples, please !

<input type="checkbox" id="product-1" name="toggle">
<input type="checkbox" id="product-2" name="toggle">
<input type="checkbox" id="product-3" name="toggle">
<input type="checkbox" id="product-4" name="toggle">
<input type="checkbox" id="product-5" name="toggle">



Aucun commentaire:

Enregistrer un commentaire