JQuery Get all checked flags with name

Im trying to get all the checkboxes with the name if the images are [].

I usually

imgs = $('input:checkbox[name=images]:checked').map(function() { return this.value; }).get(); 

Below is the code I tried and it doesn't work.

  imgs = $('input:checkbox[name=images[]]:checked').map(function() { return this.value; }).get(); 
+4
source share
1 answer

You should avoid parentheses (adding quotes will 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(); 
+13
source

Source: https://habr.com/ru/post/1492204/


All Articles