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

97
Views
React DOM Manipulation

Let me explain what my code does first. In mn there are some elements and whenever I hover the element inside it, it will add the active class (basically just change the text's color and leave the color there until I hover another element).

When I click the img which is just the logo, I expect it will remove the active class, but I don't know how to make the function, my problem is the mn is an array so I gotta iterate and make a condition or something that I don't really get the idea.

Can anyone help me? thanks before, appreciate any kinda helps

useEffect(() => {
    const mn = document.getElementsByClassName("mn");
    const logo = document.querySelector(".hd-left");
    const img = logo.getElementsByTagName("img")[0]; 

    Array.from(mn).forEach(
      (el) => {
        if (el.innerText === menuSelected.name) {
          el.classList.add("active");
        } else {
          el.classList.remove("active");
        }
      } 
    ); 
  });
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!