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

137
Views
JavaScript mutation observer for multiple nodes

I have been coding this Chrome Extension for the past few weeks, and when I was almost done and everything was working, Bybit decided to change their HTML code and consequently my code stopped working. Now, what I want to do is that I need to observe a <div> element that contains 21 <div> elements. in those 21 elements, there are 3 or 4 spans and I need to access the second span. Below is my JS code:

function obser1() {
    const trades = document.querySelector("#root > main > div.main-left > div.react-grid-layout > div:nth-child(3) > div > div.by-card__body > div > div");
    tradescards.push(trades.childNodes);
    const observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            if (mutation.addedNodes.length) {

                console.log(trades);
                console.log(mutation.addedNodes);
    });
    observer.observe(trades, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true
    })
}

Please keep in mind trades returns the parent div of the 21 divs.

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!