lundi 1 février 2016

jQuery - setting the value of single checkbox in a group checkbox

I have four checkbox like below

<label> <input type="checkbox" id="ca" value="0" name="ca"> CA </label>
<label> <input type="checkbox" id="nv" value="0" name="nv"> NV </label>
<label> <input type="checkbox" id="tx" value="0" name="tx"> TX </label>
<label> <input type="checkbox" id="fl" value="0" name="fl"> FL </label>

When user checks/unchecks each checkbox, it should change the value of the corresponding checkbox (check = 1 and uncheck = 0)

I know that I can do it by writing code separately for each checkbox.

But, I would like to know if we can write it in a single line (or in less lines) using jQuery




Aucun commentaire:

Enregistrer un commentaire