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

144
Views
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 answers
Answer question

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 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!