Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript to hover separate selection

I'm trying to do the following using JavaScript :

  1. When hovering over the map, it must mark the area below the mouse cursor.
  2. Being able to make a new window when you click that selected area.

[What i have achieved already - hover working over the rectangle on left side of map

However, I need the area to be working for other things than squares & geometric objects. What is the best/easy way to execute it so you can select areas like on the below image?

Image with selections

like image 206
Qdc Avatar asked Jul 21 '26 16:07

Qdc


1 Answers

Basically you can use area tag Like below :

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

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

Here is the link : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_areamap

So you can assign a ID to each area , and you can write hover , click codes for those in javascript.

like image 118
S.A.Parkhid Avatar answered Jul 23 '26 06:07

S.A.Parkhid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!