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

182
Views
reacting to hover over img map area outside of hierarchy

This is a prototype of what I wanted to achieve. I wanted to highlight text outside of the map when hovering over the map area. What came up with is the usage of getting element id but I'm a total beginner and cant make it work. The final version of it should not have a repeat of the selector code but one code reacting to area-id and adding "link" to it please help!


<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">

<map id="planetmap" name="planetmap">
  <area shape="rect" id="star" coords="0,0,82,126" alt="Sun" href="sun.htm">
  <area shape="circle" id="planet1" coords="90,58,3" alt="Mercury" href="mercur.htm">
  <area shape="circle" id="planet2" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

<div id="starlink" >hover over sun to make this big.</div>
<div id="planet1link" >hover over planet to make this big.</div>
<div id="planet2link" >hover over planet to make this big.</div>


<script>
document.getElementsById('star')[0].onmouseover = function(){
document.getElementsById('starlink')[0].style = "font-size: xxx-large;"
}
document.getElementsById('star')[0].onmouseout = function(){
  document.getElementsById('starlink')[0].style = "font-size: small;"
}
document.getElementsById('planet1')[0].onmouseover = function(){
document.getElementsById('planet1link')[0].style = "font-size: xxx-large;"
}
document.getElementsById('planet1')[0].onmouseout = function(){
  document.getElementsById('planet1link')[0].style = "font-size: small;"
}
document.getElementsById('planet2')[0].onmouseover = function(){
document.getElementsById('planet2link')[0].style = "font-size: xxx-large;"
}
document.getElementsById('planet2')[0].onmouseout = function(){
  document.getElementsById('planet2link')[0].style = "font-size: small;"
}

</script>
</body>```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Replace your script with this.

 window.addEventListener("DOMContentLoaded", () => {
    const shapes = document.querySelectorAll("area");
    for (let x=0, shape; shape = shapes[x]; x++)
    {
      shape.addEventListener("mouseover", () => { document.getElementById(shape.id + "link").style = "font-size: xxx-large;" })
      shape.addEventListener("mouseout", () => { document.getElementById(shape.id + "link").style = "font-size: small;" })
    }
 });
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!