vendredi 18 août 2017

How to check 0 to nth index checkbox in using jquery

I have chackboxes which i want to check and uncheck by using button

for example suppose i want check checkbox 0 to 9 should be checked then i click on "10 or less" button so other checkbox must uncheck and only that check box checked which index less then 10

Button

<button class="1-10">10 or less</button>
<button class="1-25">25 or less</button>
<button class="1-50">50 or less</button>

Checkbox

<input type="checkbox" name="age[]" class="age_opts" value="1" /> 1 <br />
<input type="checkbox" name="age[]" class="age_opts" value="2" /> 2 <br />
<input type="checkbox" name="age[]" class="age_opts" value="3" /> 3 <br />
          ...
          ...
<input type="checkbox" name="age[]" class="age_opts" value="49" /> 49<br />
<input type="checkbox" name="age[]" class="age_opts" value="50" /> 50<br />

i have used loop for this but may be there is any better way please let me know.

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire