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

138
Views
un elemento para cambiar de color mientras se desplaza sobre otro

Esto es lo que probé hasta ahora. Como están en diferentes divs y no tienen una relación de padres, hermanos o hijos entre sí, según tengo entendido, CSS no es una opción válida.

 <script> var circleOne = document.querySelector('.first_circle'); var adressOne = document.querySelector('.first_adress'); if (circleOne.matches(':hover')) { adressOne.style.color='green'; } else { adressOne.style.color='black'; } </script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede usar una combinación de onmouseenter y onmouseleave

 var circleOne = document.querySelector('.first_circle'); var adressOne = document.querySelector('.first_adress'); circleOne.onmouseenter = () => adressOne.style.color='green'; circleOne.onmouseleave = () => adressOne.style.color='black';
 <div class="first_circle">First Circle</div> <div class="first_adress">First Address</div>

about 4 years ago · Juan Pablo Isaza Report

0

Debe usar detectores de eventos mouseenter, mouseleave para esta tarea

 const firstEl = document.getElementById('first'); const secondEl = document.getElementById('second'); firstEl.addEventListener('mouseenter', () => secondEl.style.background = 'black'); firstEl.addEventListener('mouseleave', () => secondEl.style.background = 'transparent'); secondEl.addEventListener('mouseenter', () => firstEl.style.background = 'blue'); secondEl.addEventListener('mouseleave', () => firstEl.style.background = 'transparent');
 #first, #second { display: inline-block; width: 100px; height: 100px; border: 1px solid #e0e0e0; }
 <div id="first"></div> <div id="second"></div>

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!