Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
.each loop is not working in my jQuery code

The code below is written to hide the "IN STOCK" phrase on certain vendors' product pages. I noticed the loop itself isn't running when I used console.log. Could you please help correct the code?

function runPmmCustomAllPagesJs($) {
    // This function is called from argento-custom.js once dom is ready and jQuery obect is available.
    // $ has the jQuery object.

    var docloch = document.location.href,
        scree = [screen.availWidth, screen.availHeight],
        thisVal = "",
        tAlign = "left",
        afterwhat = "h3",
        df,
        hide_inStock= [':"JV', ':"KE', ':"MB', ':"WD'],
        doc_text=$(document).text(),
        v_code;
        
        
    // hides the "IN STOCK" phrase on certain vendors' product pages
    $(hide_inStock).each(function(v_code){
        console.log('v_code: ' + v_code);
        if (doc_text.indexOf(v_code)>1){
            $(".stock").hide();
            return false;
        }
    });
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When false is returned from the predicate, the iteration is ended prematurely. Return something else or even nothing if you want it to get to the end.

Also, remember that the first argument passed to .each is the index.

$([1, 2, 3]).each((_index, value) => {
    console.log(value);

    if (value === 2) {
        return false;
    }
});
// 1
// 2
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda