var fobj = document.forms[0];
var c = 0;
for (var i = 0; i < formobj.elements.length; i++)
{
if (fobj.elements[i].type == "checkbox")
{
if (fobj.elements[i].checked)
{
c++;
}
}
}
alert('Total Checked = ' + c);
If you want to use plain javascript
var checkbox = document.getElementsByName('ckbox[]');
var ln = 0;
for(var i=0; i< checkbox.length; i++) {
if(checkbox[i].checked)
ln++
}
alert(ln)
Try this,
var ch_n = $( "input:checked" ).length;
var len = $("[name='cbox[]']:checked").length;
will work but will not work if you are directly comparing like
if ( $("[name='cbox[]']").length= $("[name='cbox[]']:checked").length)
You may use as below as well
$('[name=cbox\\[\\]]:checked').length