在映射图像上检查当前正在悬停的区域
Check on a mapped image what area is currently being hovered
我需要知道用户悬停在我映射的图像上的哪个区域。我所尝试的是给不同的类的区域,并使用jQuery我检测哪一个是悬停。
这是我的html
:
<img src="test.jpg" usemap="#map" id="testMap"/>
<map id="map" name="map">
<area class="area1" shape="poly" alt="" title="" coords="37,459,145,378,111,347,17,436,25,446" href="" target="" />
<area shape="poly" alt="" title="" coords="118,460,224,379,192,347,96,436" href="" target="" />
<area class="area1" shape="poly" alt="" title="" coords="305,379,198,460,176,435,272,348" href="" target="" />
<area shape="poly" alt="" title="" coords="350,349,385,379,272,464,276,457,257,436" href="" target="" />
<area shape="poly" alt="" title="" coords="433,349,466,380,359,460,337,436" href="" target="" />
<area shape="poly" alt="" title="" coords="512,348,545,379,432,464,437,456,415,436" href="" target="" />
<area shape="poly" alt="" title="" coords="590,349,622,380,511,463,516,456,495,435,590,348" href="" target="" />
<area shape="poly" alt="" title="" coords="670,348,703,380,594,460,573,435" href="" target="" />
<area shape="poly" alt="" title="" coords="749,347,783,380,670,463,674,455,656,436" href="" target="" />
<area shape="poly" alt="" title="" coords="830,349,863,380,752,461,733,436" href="" target="" />
<area shape="poly" alt="" title="" coords="910,349,941,379,830,463,834,455,814,437" href="" target="" />
</map>
这是我用来检查hover
状态的脚本:
<script>
$(document).ready(function(){
if ($('.area1').is(':hover')) {
alert('hovered');
}
});
</script>
但是我没有得到任何结果…有人能告诉我为什么吗?
下面这些呢:
$('.area1').hover(function() {
alert('hovered');
});
http://api.jquery.com/hover/或
$('.area1').on('mouseenter', function () {
alert('mouse enter');
});
http://api.jquery.com/on/相关文章:
- 悬停时以矩形突出显示整个标签区域
- 点击悬停区域中的链接会在触摸时立即激活
- 增大悬停区域
- 如何在折线图中增加鼠标悬停在“命中区域”上
- 尝试在悬停在可单击区域时更改图像
- IE DIV悬停区域不一样.直到我添加背景颜色
- 将鼠标悬停在地图上时,取消选择图像映射的选定区域
- 仅当悬停在 、 高图表上时,才通过 x 和 y 绘图线将文本添加到生成的象限区域
- 使用 jquery 将鼠标悬停在地图区域时添加边框
- .focus() 在悬停事件中的文本区域不起作用
- 悬停时 X 区域标注
- 要更改悬停区域上的图像源
- 在区域悬停时更改 img src
- 更改jQuery Div悬停区域
- 在IE7中圈出悬停区域
- 悬停区域的射击功能
- 限制css翻转的悬停区域
- 增加SVG元素的悬停区域
- 下拉菜单:将悬停区域扩展到图像链接之外
- 扩大悬停区域,同时保持背景颜色