I have these checkboxes:
<input type="checkbox" class="ids" name="ids[]" value="2">
<input type="checkbox" class="ids" name="ids[]" value="3">
<input type="checkbox" class="ids" name="ids[]" value="4">
<input type="checkbox" class="ids" name="ids[]" value="5">
<input type="checkbox" class="ids" name="ids[]" value="6">
My question is via jquery, how would I loop through the ids[] on form submit?
$("#form").submit(function(e) {
//Loop throught ids[]
});
I have tried this:
$('input[type=checkbox][name=ids[]]').each(function () {
console.log("Here");
});
But it didn't work
each. What exactly are you wanting to accomplish?[name=ids[]]is an invalid selector. put double quotes around theids[]to force it to be a literal. But you don't have to do that. Just select using your class.