Html图像热点切换图像

时间:2015-05-15 08:13:07

标签: javascript html css onmouseover onmouseout

我在地图上有一个图像热点,在悬停时将图像扫描出来然而我想让图像保持打开更长时间并且只有当用户将光标移动到外面时才将其关闭(并更改回原始图像)新的交换图像轮廓而不是原始热点,这样可能吗?

到目前为止我的代码

<div class="mapwrap" style="text-align:center;"><img src="/dev/test/templates/jwd25template/images/map-blank.png" alt="wc" name="map" width="700" height="400" usemap="#mapMap" id="map" border="0" ></div>
<map name="mapMap">
<area shape="poly" coords="231,299,236,309,239,314,242,324,242,333,241,340,237,342,232,342,232,346,236,348,239,352,242,359,244,360,246,363,249,371,245,374,243,378,244,379,252,373,253,375,255,378,255,380,260,382,260,381,266,384,269,387,272,389,275,390,276,390,279,390,287,386,288,383,293,381,298,380,303,379,306,379,307,380,310,380,314,378,317,378,320,378,322,376,325,374,330,372,337,370,342,370,347,372,349,372,355,372,358,370,359,369,355,366,352,363,354,358,356,358,354,355,349,354,348,354,342,355,339,352,339,348,341,344,344,339,349,337,352,332,352,327,357,325,362,324,370,323,373,316,372,312,367,309,366,310,360,308,355,311,350,315,346,317,342,315,337,313,331,310,327,307,326,314,325,318,323,322,321,324,314,324,309,327,306,330,304,334,303,335,300,337,297,339,294,341,291,341,288,341,283,339,280,334,280,329,283,325,283,324,277,328,271,331,269,334,269,335,266,327,269,321,266,319,264,317,257,315,257,310,256,302,255,296,255,292,254,286,246,281,239,280,240,285,233,287,231,293,229,296,229,296" href="takke/western-cape" target="_parent" alt="WC" onMouseOver="MM_swapImage('map','','/dev/test/templates/jwd25template/images/map-WC-2.png',1)"  onMouseOut="MM_swapImgRestore('map','','/dev/test/templates/jwd25template/images/map-blank.png',1)"></map>

我尝试添加一个onMouseOut网址,但我意识到它不会工作。

试着把头包裹起来,任何想法都会非常感激:)

1 个答案:

答案 0 :(得分:0)

您可以使用CSS

执行此操作

HTML CODE:

<map id="big_map_area">
  <area shape="poly" id="map_hover" coords="231,299,2..." href="takke/western-cape" target="_parent" alt="WC">
</map>

CSS代码:

#map_hover {
opacity:0.0;
}

JQUERY CODE:

 $("#map_hover").mouseover(function () {
     this.css('opacity', '1.0');
 });
 $("#big_map_area").mouseout(function () {
     $("#map_hover").css('opacity', '0.0');
 });
  

因此,当鼠标进入地图内部的小poligon时,以及离开大地图容器时的图像交换时,显示图像。

现在应该可以了。