mercredi 2 décembre 2020

How to check child checkboxs when the main one is checked using React?

I want to dynamically check the childrens checbox when the main one is checked. I found some solutions and other related post on Stackoverflow but they are always using JQuery. I want to achieve that using ReactJS, here is a snippet with my code.

ul {
    list-style-type: none;
}
<div>
<input type="checkbox" id="fullbody" />
<label htmlFor="fullbody">Download the points for the full body</label>
<ul>
    <li><input type='checkbox' id="upperbody"/>Download only the upper body points</li>
    <li><input type='checkbox' id="lowerbody" />Download only the lower body points</li>
    <li><input type='checkbox' id="head" />Download only the head points</li>
    <li><input type='checkbox' id="fullhands" />Download both hands points</li>
    <li><input type='checkbox' id="lefthand" />Download left hand points</li>
    <li><input type='checkbox' id="righthand" />Download right hand points</li>
</ul>
</div>

so my question, how can I dynamically check the childrens checkbox when fullbodyis checked ?

Thank you




Aucun commentaire:

Enregistrer un commentaire