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

1

446
Views
How to convert JS code to React by onMouseEnter, onMouseLeave or something better
const w_phones = document.querySelectorAll('.w-nav__btn');

w_phones.forEach(w_phone => {
  const item_data = w_phone.dataset.phone
  const item = document.getElementById(item_data);

  console.log(item)

  w_phone.onmouseover = function () {
    item.classList.add('active')
  };

  w_phone.onmouseout = function () {
    item.classList.remove('active')
  };
});

I need to convert this code to React. Code of buttons look like this enter image description here

Class active must be here enter image description here "w-phones__item w-phones__item--1 active" and on 2, 3

How to fix this? THIS

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

0

There's no need for javascript if all you want to do is add a css class. The :hover pseuedoselector will only take effect when the user is hovered over the .w-nav__ and you can apply the style to the phone items below it like this.

.w-nav__btn:hover .w-phone__item {
   color: red;
}
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!