Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

        }       
})
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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

if ($checkboxItems[0].checked && $checkboxItems[1].checked)
about 4 years ago · Juan Pablo Isaza Report

0

I don't know of the existence of a each function, however if you need to check if the first two elements of an array are true I will go with @David Thomas solution

$checkboxItems.slice(0,2).every((el) => el.value);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!