Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  37] [ 4]  / answers: 1 / hits: 22608  / 11 Years ago, fri, july 19, 2013, 12:00:00

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();

More From » jquery

 Answers
13

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();

[#76888] Thursday, July 18, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ethanc

Total Points: 57
Total Questions: 111
Total Answers: 111

Location: Vanuatu
Member since Fri, May 13, 2022
2 Years ago
;