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

117
Visualizações
How to replace each value that is already stored in a array JQUERY

May I know how I can replace each DOM value that is already stored in an Array?

$(document).ready(function() {
  $(".compare-filter-item").click(function() {
    var column_value = $(this).attr("data-column");
    var selected_data_product = $(this).attr("data-product");

    var myarray = [];

    $(".compare-all .compare-products [data-product='" + selected_data_product + "']").each(function(index, value) {
      var value = $(this).html();
      myarray[index] = value;
    });

    $(".compare-main .compare-products [data-column='" + column_value + "']").each(function(index, value) {
      // I WANT TO REPLACE EACH OF THE VALUE HERE WITH THE ONES STORED IN ARRAY
    });

  });
});

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

0

Like this

$(function() {
  $(".compare-filter-item").on("click",function() {
    const column_value = $(this).attr("data-column");
    const selected_data_product = $(this).attr("data-product");

    const myarray = $(`.compare-all .compare-products [data-product="${selected_data_product}"]`).map(function() {
      return $(this).html();
    });

    $(`.compare-main .compare-products [data-column="${column_value}"]`)
     .each(function(i) { $(this).html(myarray[i]) });
  });
});

or even this if there is one to one relationship

$(function() {
  $(".compare-filter-item").on("click",function() {
    const column_value = $(this).attr("data-column");
    const selected_data_product = $(this).attr("data-product");
    const $myarray = $(`.compare-all .compare-products [data-product="${selected_data_product}"]`);

    $(`.compare-main .compare-products [data-column="${column_value}"]`)
      .each(function(i) { $(this).html(myarray[i].html()) });
  });
});
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