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

101
Views
How to target specific tag in Mutation Observer

I'm trying something like this:

var pin = document.querySelector("#notice ul li div p a");

The idea is to narrow down the observer and filter only the relevant element(s) in this case all 'a' inside the nested tags. The ID 'notice' is the only tag with an ID, I then need to select the first 'ul' then 'li' and so on, until I reach the 'a' I'm interested in.

Passing this to the observer, which is listening with the following options:

const config = { attributes: true, childList: true, subtree: true };

So I have the observer.observe(pin, config); and relative let observer = new MutationObserver(mutations => { However I must be doing something wrong sing it is not pulling anything. It only works if I use this:

var pin = document.querySelector("#notice");

How can I limit the observer to only relevant portion I'm interested in? I know I could monitor the whole document body, but will affect CPU load and do unnecessary operations since what I need to isolate in just a specific tag.

this is the sample HTML I'm workin on

<section id="notice">
<ul>
   <li>      
      <div>  
          <p>
            <a href="locale.html?58651456454">Translate</a>
      </p>
      </div>
   </li>
</ul>
</section>

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!