image map访问ID(区域)

image map access ID (area)

本文关键字:区域 ID map 访问 image      更新时间:2023-09-26

我有一个图像映射,我希望多边形将高亮显示,直到下一个多边形被点击。

喜欢:点击plogone 1 -成为突出显示

than:点击多边形2 -高亮显示(多边形1未高亮显示)

<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery.maphilight.js"></script>
<script>
$(function() {
 var nr = 0;
$('.map').maphilight({ strokeColor: 'ff0000', strokeWidth: 5});
$(polymap).click(function(e) {
            var data = $(high1).mouseout().data('maphilight') || {};
            data.alwaysOn = !data.alwaysOn;
            $(high1).data('maphilight', data).trigger('alwaysOn.maphilight');
            });
  });

</head>
  <body>
    <br>
    <img class="map" src="pb90%20%28150%29.html.png" ismap="ismap" usemap="#mapmap" alt="html imagemap created with QGIS" border="0">
    <map id="polymap" name="mapmap">
      <area id='high1'  shape="poly" href="PDF1.pdf" target="cont" coords="834,366,837,363,840" alt="">
      <area id='high2'  shape="poly" href="PDF2.pdf" target="cont" coords="940,236,941,236" alt="">
      <area id='high3'  shape="poly" href="PDF3.pdf" target="cont" coords="831,345,828,348,824" alt="">
....

我的问题是我无法访问区域的ID。如果你点击多边形,只有"high1"区域会高亮显示。所以不用

$(high1).

我需要一种事件处理程序。

如果有人知道解决办法那就太酷了:-)

欢呼伊曼努尔

您的jquery选择器可以在area上,然后在单击事件上运行的函数将取决于您单击的区域。在函数中,您可以使用this关键字来引用调用对象。

   $('area').click(function (e) {
        var data = $(this).mouseout().data('maphilight') || {};
        data.alwaysOn = !data.alwaysOn;
        $(this).data('maphilight', data).trigger('alwaysOn.maphilight');
    });