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

119
Visualizações
Cómo llamar a dos salidas del retorno de función anterior

Tengo una función que busca cualquier imagen que esté "marcada" y devuelve el atributo img "Alt" para cada imagen marcada.

La salida/retorno son 2 números separados.

Solicitud Estoy tratando de descubrir cómo configurar ambos números de salida como dos nuevas variables para una nueva función que estoy escribiendo que usará este valor img Alt.

 $("#NFTGallery2 > li > input:checked").each(function(){ var imgAtt = $(this).siblings("label").find("img").attr("alt"); console.log(imgAtt); return imgAtt }); //this returns two numbers such as 1 20
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="sc-jRQBWg hdgczQ"> </div> <div id="NFTGallery2" class="sc-fubCzh hohBlo" style="text-align: center; color: rgb(255, 29, 236);"> <li> <input type="checkbox" id="myCheckbox2"> <label for="myCheckbox2"><img alt="2" 'width="256px" height="256px" src="xxxxx"></label></li><li><input type="checkbox" id="myCheckbox10"><label for="myCheckbox10"><img alt="10" 'width="256px" height="256px" src="xxxxx"></label> </li> <li> <input type="checkbox" id="myCheckbox7"> <label for="myCheckbox7"><img alt="7" 'width="256px" height="256px" src="xxxxx"></label></li><li><input type="checkbox" id="myCheckbox15"><label for="myCheckbox15"><img alt="15" 'width="256px" height="256px" src="xxxxx"></label> </li> <li> <input type="checkbox" id="myCheckbox8"> <label for="myCheckbox8"> <img alt="8" 'width="256px" height="256px" src="xxxxx"></label></li></div>

¿Cómo configuro las dos salidas como Var1 y Var2?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Puede usar map() que le permitirá tener una matriz de elementos. También puede hacer un selector que le evitará tener que buscar dentro de cada uno.

 const alts = $("#NFTGallery2 > li > input:checked + label img").map(function (){ return this.alt }).get(); console.log(alts);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="sc-jRQBWg hdgczQ"> </div> <div id="NFTGallery2" class="sc-fubCzh hohBlo" style="text-align: center; color: rgb(255, 29, 236);"> <li> <input type="checkbox" id="myCheckbox2" checked> <label for="myCheckbox2"><img alt="2" 'width="256px" height="256px" src="xxxxx"></label></li><li><input type="checkbox" id="myCheckbox10"><label for="myCheckbox10"><img alt="10" 'width="256px" height="256px" src="xxxxx"></label> </li> <li> <input type="checkbox" id="myCheckbox7"> <label for="myCheckbox7"><img alt="7" 'width="256px" height="256px" src="xxxxx"></label></li><li><input type="checkbox" id="myCheckbox15"><label for="myCheckbox15"><img alt="15" 'width="256px" height="256px" src="xxxxx"></label> </li> <li> <input type="checkbox" id="myCheckbox8" checked> <label for="myCheckbox8"> <img alt="8" 'width="256px" height="256px" src="xxxxx"></label></li></div>

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