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

124
Views
Using MutationObserver to log changes

I want to be able to console.log out the price each time the price changes. I'm trying to use MutationObserver to do this which does seem to work when the price is changed, that a price is logged out. But for some reason I keep logging out the same price i.e the cheapest size. Any ideas where I'm going wrong?

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

observer.observe(elementToObserve, {
  subtree: true,
  childList: true
});

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

0

Instead of using .innerHTML to get the inner content, try using .textContent

console.log(size.textContent);

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!