html area标签用jquery鼠标悬停事件显示中国地图热点地区数据信息提示框



463 1848 617



特效描述:area标签 鼠标悬停 中国地图 数据信息提示框,

代码结构

1. 引入JS

<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>

2. HTML代码

<div class="ConDiv">
	<img border="0" usemap="#Map" src="images/eg/map.png" />
	<map name="Map" id="Map">
		<area id="beijing" alt="北京" href="http://www.17sucai.com/" coords="354,140,380,153" shape="rect">
		<area id="shanghai" alt="上海" href="http://www.17sucai.com/" coords="434,246,462,259" shape="rect">
		<area id="tianjin" alt="天津" href="http://www.17sucai.com/" coords="382,168,408,180" shape="rect">
		<area id="chongqing" alt="重庆" href="http://www.17sucai.com/" coords="294,264,320,276" shape="rect">
		<area id="hebei" alt="河北" href="http://www.17sucai.com/" coords="347,174,374,186" shape="rect">
		<area id="shanxi" alt="山西"  href="http://www.17sucai.com/" coords="322,186,348,198" shape="rect">
		<area id="neimenggu" alt="内蒙古" href="http://www.17sucai.com/" coords="349,110,388,124" shape="rect">
		<area id="liaoning" alt="辽宁" href="http://www.17sucai.com/" coords="406,128,432,140" shape="rect">
		<area id="jilin" alt="吉林" href="http://www.17sucai.com/" coords="427,101,454,115" shape="rect">
		<area id="heilongjiang" alt="黑龙江" href="http://www.17sucai.com/" coords="424,58,464,73" shape="rect">
		<area id="jiangsu" alt="江苏" href="http://www.17sucai.com/" coords="404,224,417,250" shape="rect">
		<area id="zhejiang" alt="浙江" href="http://www.17sucai.com/" coords="413,265,427,291" shape="rect">
		<area id="anhui" alt="安徽" href="http://www.17sucai.com/" coords="382,236,395,263" shape="rect">
		<area id="fujian" alt="福建" href="http://www.17sucai.com/" coords="399,300,413,327" shape="rect">
		<area id="jiangxi" alt="江西" href="http://www.17sucai.com/" coords="371,286,385,313" shape="rect">
		<area id="shandong" alt="山东" href="http://www.17sucai.com/" coords="373,196,399,208" shape="rect">
		<area id="henan" alt="河南" href="http://www.17sucai.com/" coords="337,228,364,239" shape="rect">
		<area id="hubei" alt="湖北" href="http://www.17sucai.com/" coords="329,258,356,271" shape="rect">
		<area id="hunan" alt="湖南" href="http://www.17sucai.com/" coords="325,294,352,306" shape="rect">
		<area id="guangdong" alt="广东" href="http://www.17sucai.com/" coords="356,343,382,355" shape="rect">
		<area id="guangxi" alt="广西" href="http://www.17sucai.com/" coords="302,343,328,355" shape="rect">
		<area id="hainan" alt="海南" href="http://www.17sucai.com/" coords="313,398,340,411" shape="rect">
		<area id="sichuan" alt="四川" href="http://www.17sucai.com/" coords="239,265,265,277" shape="rect">
		<area id="guizhou" alt="贵州" href="http://www.17sucai.com/" coords="283,311,308,324" shape="rect">
		<area id="yunnan" alt="云南" href="http://www.17sucai.com/" coords="225,337,251,349" shape="rect">
		<area id="shaanxi" alt="陕西" href="http://www.17sucai.com/" coords="303,224,316,251" shape="rect">
		<area id="gansu" alt="甘肃" href="http://www.17sucai.com/" coords="179,156,205,168" shape="rect">
		<area id="qinghai" alt="青海" href="http://www.17sucai.com/" coords="174,206,200,218" shape="rect">
		<area id="ningxia" alt="宁夏" href="http://www.17sucai.com/" coords="277,188,290,212" shape="rect">
		<area id="xinjiang" alt="新疆" href="http://www.17sucai.com/" coords="85,140,111,152" shape="rect">
		<area id="xizang" alt="西藏" href="http://www.17sucai.com/" coords="87,249,113,261" shape="rect">
		<area id="xianggang" alt="香港" href="http://www.17sucai.com/" coords="379,358,406,370" shape="rect">
		<area id="aomen" alt="澳门" href="http://www.17sucai.com/" coords="349,371,375,383" shape="rect">
		<area id="taiwan" alt="台湾" href="http://www.17sucai.com/" coords="434,322,448,348" shape="rect">
	</map>
</div>
<script type="text/javascript">
$(function(){
	$("area").each(function(){
		var $x=-70;
		var $y=-80;	
		var name=$(this).attr("alt");	
		$(this).mouseover(function(e){
			var index_num=$(this).index();
			var dom="<div class='mapDiv'><p>提示消息<span class='name'></span><span class='num'></span></p></div>";
			$("body").append(dom);
			$(".name").text(name);
			$(".num").text(index_num)
			$(".mapDiv").css({
					top: (e.pageY + $y)+"px",
					left: (e.pageX + $x)+"px"
				}).show("fast");
		}).mouseout(function(){				
				$(".mapDiv").remove();
		}).mousemove(function(e){
				$(".mapDiv").css({
					top: (e.pageY + $y)+"px",
					left: (e.pageX + $x)+"px"
			})
		});
	});		   
});
</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 右键菜单 文字提示框 提示框/弹出层 layer lightbox Tooltip工具提示框 浮动提示框 html5弹窗动画 弹出层拖动 窗口提示框

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到