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

110
Views
Observe change and logging it outJS

On our website when you click on one of the size's it would display a different price per size which works fine. For example size a = $10, size b = $20, size c = $30. What I'm trying to do however is when the price changes I want to take that value and use it to run another calculation.

The issue I have is that when I try and observe the change the value always stays the same i.e the price for size a ($10) gets printed each time. Not sure if anyone can help - below is a mockup example of how the code looks similar to onsite.

const elementToObserve = document.querySelector(".container");
const price = document.querySelector('.price');
const observer = new MutationObserver(function() {
  console.log(price.innerHTML);
});

observer.observe(elementToObserve, {
  subtree: true,
  childList: true
});
<div class='container'>
<ul class='buttons'>
  <li>size a</li>
  <li>size b</li>
  <li>size c</li>
</ul>

<p class='price'></p>
</div>

about 4 years ago · Juan Pablo Isaza
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!