ImageMapster - 在文本链接悬停上显示图像映射区域

时间:2013-02-14 13:39:12

标签: hyperlink hover imagemap imagemapster

我有一个使用ImageMapster.js的悬停效果的图像地图...图像旁边是一个文本链接列表,它指的是图像地图区域的某些区域。当我将鼠标悬停在文字链接上时,是否可以突出显示图像地图区域?

e.g:

<img src="map.png" usemap="#ch" style="width:100%;">
<map id="usa_image_map" name="usa>
<area href="http://ab.com" state="ab" shape="poly" coords="259,256,275,257,..."><area href="http://xy.com" state="xy" shape="poly" coords="332,421,329,416,...">
</map>
<div id="links">
<a href="http://ab.com">ab</a><a href="http://xy.com">xy</a>
enter code here

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这个:

    $("a", "#links").hover(
      function () {
        var state = $( this ).text();
        $( 'area[state="' + state +'"]').mapster('select');

    });

当您将链接列表悬停在id="links"时,这是一个活动的事件。 var状态保存悬停链接的文本,因此当您悬停<a href="ab.com">ab</a>时,状态为ab。使用选择器$('area[state="' + state +'"]'),您可以找到地图的area元素,其state属性等于hovered链接的文本。 mapster('select')最终突出显示地图区域。

相关问题