gpt4 book ai didi

jquery - 如何通过将鼠标悬停在另一个映射图像区域上来显示小图像和段落?

转载 作者:行者123 更新时间:2023-11-28 13:27:36 26 4
gpt4 key购买 nike

这会比我的话更好地解释我想要的东西: 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">

最佳答案

使用 jQuery mouseover事件。

您可以将其附加到文档就绪的“区域”标签上。

$(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.
});
});

关于jquery - 如何通过将鼠标悬停在另一个映射图像区域上来显示小图像和段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13976601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com