想要在区域悬停时更改图像源

时间:2014-11-06 16:31:10

标签: javascript jquery html css

想要在悬停地图的任何区域时加载不同的图像。



<img src="images/mapimg.png" usemap="#states" />
<map name="states">
  <area shape="poly" coords="4,349,121,416,111,205" title="test1">
  <area shape="poly" coords="226,287,234,255,132,231,129,402,151,404,150,429,362,465,362,385,283,359" title="test" />
</map>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

有很多改进空间,但基本上就像

 <img id="map" src="images/mapimg.png" usemap="#states" />
 <map name="states">
     <area style="background-color: black;" onmouseover="document.getElementById('map').src = 'other.png';" shape="poly" coords="4,349,121,416,111,205" title="test1">
     <area shape="poly" coords="226,287,234,255,132,231,129,402,151,404,150,429,362,465,362,385,283,359" title="test" />
 </map>