views:

57

answers:

2

There are multiple <input type="checkbox" value="..." /> in the page.

I need to get each of the <input> that is checked to do some operation.

I'm using jQuery.

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

or you can use

$("input:checkbox")

selector

If all the checkboxes are inside a container then you can narrow the selector by using

$("#containerID input[type=checkbox]:checked" )
rahul
A: 

You can also try this:

$(":checkbox :checked").each(function(){
  alert( $(this).val() );
});
jerjer
From jQuery docs; $(':checkbox') is equivalent to $('*:checkbox') which is a slow selector. It's recommended to do $('input:checkbox').
rahul