I check other answer for similar problem, so either with this question:
Need select all Input:Checkbox from a Form but identifying his ID.
I try with: $( "input:checkbox[id^='ingr_']" ) and run perfect for "Checked" elements. So the unchecked elements, jquery said to use :not(:checked). Put this on the code then obtain nothing (checked or unchecked).
This is my sample code running on fiddle: JsFiddle
2 Answers
I think the problem come from serializeArray() method. It removes unchecked checkbox.
https://api.jquery.com/serializeArray/
If you made a console.log of
$ ('input:checkbox[id^='comp_']:not(:checked)') , it works well.
2 Comments
Mastercafe
Thanks, efectively serialize remove unchecked fields. How to emulate serializeArray to use this selection?
Mastercafe
The solution was simply eliminate serializeArray because next line construct the string with selector
$( "input[id^='ingr_']:checkbox")