that are checked? There are several on the page . ...">

How to get flag values ​​<input type = "checkbox" / "> that are checked?

There are several on the page <input type="checkbox" value="..." />.

I need to get each of the marked <input>in order to perform some operation.

I am using jQuery.

+3
source share
2 answers
$("input[type=checkbox]:checked").each ( function() {
   alert ( $(this).val() );
});

or you can use

$("input:checkbox")

Selector

If all the checkboxes are inside the container, you can narrow the selector using

$("#containerID input[type=checkbox]:checked" )
+9
source

You can also try the following:

$(":checkbox :checked").each(function(){
  alert( $(this).val() );
});
-1
source

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


All Articles