1

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

例如:

<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>
4

1 回答 1

1

尝试这个:

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

    });

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

于 2013-03-28T08:55:33.963 回答