'Get selected checkbox using id or name

I'm using this code to get all the selected checkboxes. My problem is it loops through all checkboxes. How to only loop by checkbox id or name?

$('input.form-check-input:checkbox:checked').each(function() {}


Solution 1:[1]

That would give you a lot of pain. Instead set id numbers for each of them. And then try to get their value with .val() since you are using jquery. A checked one will return some value other wise it will not.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sohan Arafat