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

92
Views
Salir $('input[name^="myname"]').each( function() {

Necesito salir del javascript pero estoy obteniendo algo extraño.

Hay una serie de entradas que esto utiliza.

Cuando la declaración "si" es verdadera y "devolver verdadero" o "devolver falso" se va a ejecutar, la alerta ('algo') se ejecuta y veo la ventana emergente.

El script continúa ejecutándose.

No sé si aún ejecuta el bucle "..each". ¿Tú?

Esto necesita salir del bucle y del script .each por completo.

Si ninguna casilla de verificación es falsa, ejecute el código de alerta fuera de ...each(function()...

 <input type="checkbox" id="a" name="test[]" onclick="myfunction('a');" /> <input type="checkbox" id="b" name="test[]" onclick="myfunction('b');" /> <input type="checkbox" id="c" name="test[]" onclick="myfunction('c');" />

y el guion...

 <script> function myfunction(instuff) { $('input[name^="test"]').each(function() { if ($(this).prop('checked') == false) { //...run code... return true; //return false; acts the same. } }) //...run other code... alert('something'); } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

return false de la función de devolución de llamada detendrá el .each() . Pero el resto de myfunction() seguirá ejecutándose.

Si desea detener el resto de la función, puede establecer una variable que verifique después del ciclo.

 function myfunction(instuff) { let stop = false; $('input[name^="test"]').each(function() { if (!$(this).prop('checked')) { stop = true; return false; } } // fixed the code typo ) if (stop) { return; } //...run other code... alert('something'); }

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!