0

这将比我的话更好地解释我想要的:http: //jquery-image-map.ssdtutorials.com/ 尽管该教程可用,但它是使用 Photoshop 中的图像叠加完成的。但我正在使用 jquery 插件“jquery.maphilight.js”突出显示我的映射图像。使用它我有一个映射的图像,如果我将鼠标悬停在图像上,它会突出显示映射的部分。如果有人将鼠标悬停在特定房间(映射部分)上,我如何显示小图片和段落。

这是javascript:

 $(function () {
        $(".mapping").maphilight();
        $("#mapping").css('visibility','hidden')

    $(".hoverable").css("border", "3px solid red");

&这是图像映射的html:

<div class="mapping"> 
<map name="gmap">
<area shape="poly" id="cr1" coords="550,277,485,342,533,385,597,322" href="#" alt="cr1" name="room-1">
<area shape="poly" id="cr2"coords="579,246,627,200,672,246,624,290" href="#" alt="cr2" name="room-2">
4

2 回答 2

0

使用jQuery 鼠标悬停事件。

您可以将其附加到准备好的文档上的“区域”标签上。

$(document).ready(function(){
    //this selector is selecting an element by the id of cr1.
    $('#cr1').on('mouseover', function(){
        //do your showing here
    });

    $('#cr1').on('mouseleave', function(){
        //do your hiding here
    });
});

对于通用处理程序,您可以这样做:

$(document).ready(function(){
    //this is an attribute selector.
    //'area' is the typ of tag to match
    //[name indicates the attribute is named 'name'
    //^= indicates the attribute 'name' should start with the value following this operator
    //'room'] think of this as indicating the value of the name attribute
    // should match: 'room*'
    $('area[name^="room"]').on('mouseover', function(){
        //do your showing here, be sure to show only 
        //for the appropriate area. Maybe select on the id.
    });

    $('area[name^="room"]').on('mouseleave', function(){
        //do your hiding here. This could be generic unless you have
        //a multi-paragrah area instead of a single display area.
    });
});
于 2012-12-20T16:46:50.670 回答
0

这是我为使其工作所做的:我创建了一个具有“mouseover”和“mouseleave”属性的 div。在其中我收到了另一个元素的 id,当我将鼠标悬停在这个 div 上时,我想出现这个元素。

<div  
    onmouseover="document.getElementById('div1').style.display = 'block';"  <!-- element inside brackets will be shown-->
    onmouseout="document.getElementById('div1').style.display = 'none';"> 
<area shape="poly" id="cr1" class="jTip" coords="550,277,485,342,533,385,597,322"
href="car_park_1.html" alt="cr1" name="room-1">
</div>

我发布了自己的答案,以便它也可以帮助其他人做同样的任务:)

于 2012-12-21T11:53:16.613 回答