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

109
Views
Specify which element triggered MutationObserver on multiple elements

With the help of the following SO-post. I know it is possible to track multiple elements with a single MutationObserver-object. I want to track the text of two elements on a website, so I write the following script:

var seconds = document.getElementsByClassName('sr-lmt-0-ms-countdown__time srt-primary-7 srm-large')[2];
var minutes = document.getElementsByClassName('sr-lmt-0-ms-countdown__time srt-primary-7 srm-large')[3];


var callback = function(mutations) {
    for (var mutation of mutations) {
            // do something
            // console.log(mutation + (minutes or seconds));
        }
    };

var observer = new MutationObserver(callback);
var config = {characterData: true, subtree: true};

observer.observe(minutes, config);
observer.observe(seconds, config);

How can I alter this script so the Console shows which variable triggered the MutationObserver?

Edit

If I inspect mutation.target I see the following:

enter image description here

I don't see whether sec or minutes triggered the mutation? How can I make this distinguishing?

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

0

let observer = new MutationObserver(mutationRecords => {
  console.log(mutationRecords); // console.log(the changes)
});

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!