Q:

How to iterate selected list of checkbox in jquery using for loop not by for each loop

I am having three checkboxes in my page i want to get all selected checkboxes values how can i achieve this using normal for loop in jquery.
for ( var i = 0; i < $(":checkbox:checked").length; i++ ) { 
alert($(":checkbox:checked")[i].attr('id'));
}

A:

Try this,
$checkboxes=$(":checkbox:checked");
for ( var i = 0,len=$checkboxes.length; i < len; i++ ) { 
    alert($($checkboxes[i]).attr('id'));
    // or simply use alert($checkboxes[i].id);
}

Fiddle

