How to check in a each() function if the first and the second matched element have the prop checked ?
$(document).on('click', '#submitBtn', function(e) {
var $this = $(this),
$checkboxItems = $('input:checkbox[name="checkbox-acceptance"]');
$checkboxItems.each(function( index ){
// if index 0 and index 1 have .prop( 'checked ' ) do stuff ..
}
})
Advertisement
Answer
You don’t want to use each for this. Just check the values with simple indexing:
if ($checkboxItems[0].checked && $checkboxItems[1].checked)