javascript - How to check 0 to nth index checkbox in using jquery -


i have checkboxes want check , uncheck using button

for example suppose want check checkbox 0 9 should checked click on "10 or less" button other checkbox must uncheck , check box checked index less has 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 may there better way please let me know.

thanks in advance

you'll want use .slice(n, n+1) slice out checkboxes want. please see following question shares lot of similarity yours:

selecting first "n" items jquery


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -