HTML CODE:
<form id="myform">
<input type='checkbox' name='foo[]' value='1'>
<input type='checkbox' name='foo[]' checked='true' value='2' >
<input type='checkbox' name='foo[]' value='3' >
<input type='checkbox' name='foo[]' checked='true' value='4' >
</form>
JS CODE:
$('input[name=foo]:checked').each(function(i,el){
if(clusterVal == 'ALL')
{
/* what do I have to do here? */
}
array.push($(el).val());
});
how to check/uncheck checkbox by using value in query
As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.
try this ..but this to just demo how to do check and uncheck
DEMO