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

110
Views
Remove/Add Class on menu hover

I have tried so many ways to simply get a class to change on an image when I hover over a menu item and it is driving me bonkers. If someone can help me get this straight I would appreciate some help... In the end I will have three of these in place, one for Red, Yellow, and Blue... here is what I have for one example...

<script>
const triggerRed = document.getElementsByClassName('gardenBtn');
const redIMG = document.getElementById('gardenMe');
// ๐Ÿ‘‡๏ธ Change
triggerRed.addEventListener('mouseover', function handleMouseOver() {
  list = redIMG.classList;
  list.remove('risoMe');
});
// ๐Ÿ‘‡๏ธ Change back
triggerRed.addEventListener('mouseout', function handleMouseOut() {
  list = redIMG.classList;
  list.add('risoMe');
}); 
</script>

But nothing changes

almost 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

I don't see anywhere you declaring list variable. Anyway, if you want to add a class to that element:

list.classList.add('class-name');

if you want to remove a class:

list.classList.remove('class-name');
almost 4 years ago ยท Santiago Trujillo 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!