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

253
Vistas
How to get a specific attribute value content on each loop jquery

Can anyone tell me how I can get all the values on a specific attribute value on each loop ? I'm trying to get all the html values on each loop that has the specific attribute value( data-product=momentum-shorts ) <p>Two-Way Stretch </p> in this case..

This is my code

<script>
    jQuery( document ).ready(function() {
        $(".compare-main .compare-products").each(function(){
                $(this).each(function(){
                    console.log($(this).html());
                })
            });
        });
</script>

enter image description here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can use the jQuery attr() method

about 4 years ago · Juan Pablo Isaza Denunciar

0

$(this).data('column') or $(this).data('product')

.data()

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use the attribute equals selector :

$(".compare-main .compare-products [data-product='momentum-shorts']").each(function(){
  console.log($(this).html().trim());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="compare-main">
  <div class="compare-products">
    <div data-product="momentum-shorts">
      <p>Two-Way Stretch</p>
    </div>
    <div data-product="foo">
      <p>foo</p>
    </div>
  </div>
  <div class="compare-products">
    <div data-product="bar">
      <p>bar</p>
    </div>
    <div data-product="momentum-shorts">
      <p>Medium Weight</p>
    </div>
  </div>
</div>

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