Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Check if each() index 1 et index 2 has .prop( 'checked' )

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 ..

        }       
})

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You don’t want to use each for this. Just check the values with simple indexing:

if ($checkboxItems[0].checked && $checkboxItems[1].checked)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading