Reputation: 3800
Im trying to get all checked boxes with a name if images[].
I would usually
imgs = $('input:checkbox[name=images]:checked').map(function() { return this.value; }).get();
The below code is what I have tried and isnt working.
imgs = $('input:checkbox[name=images[]]:checked').map(function() { return this.value; }).get();
Upvotes: 4
Views: 23350
Reputation: 318342
You should escape the brackets (adding quotes would also avoid the problem, but escaping special characters is still good practice):
imgs = $('input[type="checkbox"][name="images\\[\\]"]:checked').map(function() { return this.value; }).get();
Upvotes: 15