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

104
Views
Cómo reemplazar el html interno al hacer clic en cada bucle

Estoy tratando de recorrer cada uno de los atributos y, si coincide, reemplazará el HTML interno del DOM. Para este ejemplo, estoy tratando de reemplazar el DOM HTML interno de data-product="momentum-shorts-2-0", que es el contenido de <h2>Momentum Shorts 2.0 NEW</h2> en <div> class="compare-main" </div> que he resaltado en la captura de pantalla...

Esto es lo que tengo con mi código ahora, pero estoy atascado... me sigue devolviendo el valor singular del último elemento...

 <script> jQuery( document ).ready(function() { $( ".compare-filter-item" ).click(function() { var selected_data_product = $(this).attr("data-product"); $(".compare-all .compare-products [data-product='" + selected_data_product + "']").each(function(){ new_html = $(this).html(); $(".compare-main .compare-products [data-product='" + selected_data_product + "']").each(function(){ $(this).html(new_html); }) }); }); }) </script>

ingrese la descripción de la imagen aquí

Tema:

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<script> jQuery( document ).ready(function() { $( ".compare-filter-item" ).click(function() { var selected_data_product = "momentum-shorts-2-0"; $(".compare-main .compare-products [data-product='" + selected_data_product + "']").each(function(){ $(this).find("h2").text("Momentum Shorts 2.0"); }); }); }) </script>

Traté de entender su requerimiento y aquí está la solución para ver si ayuda.

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!