Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda