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

143
Visualizações
On load instead of document ready with other javascript on page?

I currently have this bit of code going that looks for a certain class and adds the QTY text inside the class. I have to do it this way as I don't have access to the base HTML code for this portion of the site, but rather can do so via JS access.

The current code I have running is as follows:

$('.cart-product-qty').each(function() {
  $(this).prepend("QTY: ");
});

But the problem I just ran into is when certain functions are performed in the shopping cart it doesn't refresh, so it ends up dropping the QTY text. Is there another method so that it keeps it there continuously even if the page "refreshes"?

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

0

Listen to the parent div underneath the products will be listed. So whenever the content changes, you can trigger your function.

DOMSubtreeModified event might be helpful.

var element = document.getElementById('div');

element.addEventListener('DOMSubtreeModified', updateQtyText);

function updateQtyText(e) {
    $('.cart-product-qty').each(function() {
     $(this).prepend("QTY: ");
   });
}

Reference : fire a call when inner HTML changes.

This might help

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