当前位置:Gxlcms > JavaScript > jQuery实现鼠标经过提示信息的地图热点效果

jQuery实现鼠标经过提示信息的地图热点效果

时间:2021-07-01 10:21:17 帮助过:24人阅读

jQuery实现鼠标经过提示信息的地图热点效果

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>地图热点效果-鼠标经过弹出提示信息</title>
  5. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  6. </head>
  7. <script src="/ajaxjs/jquery-1.6.2.min.js" type="text/javascript"></script><!-- 建议用1.7的jquery -->
  8. <script type="text/javascript">var jq = jQuery.noConflict();</script><!-- 为了让DZ X2支持jquery 加载时替换库中的$为jq -->
  9. <style type="text/css">
  10. .map img { width:496px; height: 415px; }
  11. .mapDiv { padding: 5px; width:170px; height:61px; color:#369; background: url('hotarrow.gif') no-repeat; }
  12. </style><!-- CSS样式 -->
  13. <body>
  14. <!-- JS 如果需要读取变量最好写在网页里,也可以写在JS文件里!-->
  15. <script type="text/javascript">
  16. jq(document).ready(function(){
  17. jQuery.fn.extend({
  18. TitleShow: function(strHTML) {
  19. var xOffset = 80;
  20. var yOffset = -75;
  21. var preview = jq("#preview_container");
  22. if(preview.length<=0){
  23. jq("body").append("<div id='preview_container'></div>");
  24. preview = jq("#preview_container");
  25. }
  26. preview.css({
  27. "display":"none",
  28. "position":"absolute",
  29. "width":"150px",
  30. "word-break":"break-all"
  31. });
  32. return this.each(function() {
  33. var _this = jq(this);
  34. _this.hover(
  35. function(e){
  36. preview.html(strHTML);
  37. preview
  38. .css("top",(e.pageY - xOffset) + "px")
  39. .css("left",(e.pageX + yOffset) + "px")
  40. .css("opaticy",0)
  41. .show()
  42. .stop()
  43. .animate({"opacity":0.9},300);
  44. },function(){
  45. preview
  46. .stop()
  47. .animate({"opacity":0},300,function(){
  48. jq(this).hide();
  49. });
  50. }
  51. )
  52. _this.mousemove(function(e){
  53. preview
  54. .css("top",(e.pageY - xOffset) + "px")
  55. .css("left",(e.pageX + yOffset) + "px");
  56. });
  57. });
  58. }
  59. });
  60. jq("#beijing").TitleShow("<div class='mapDiv'>北京地图热点效果-这里是测试换行效果-这里是测试换行效果</div>");
  61. jq("#tianjin").TitleShow("<div class='mapDiv'>天津地图热点效果2</div>");
  62. jq("#shanghai").TitleShow("<div class='mapDiv'>上海地图热点效果3</div>");
  63. jq("#chongqing").TitleShow("<div class='mapDiv'>重庆地图热点效果4</div>");
  64. jq("#hebei").TitleShow("<div class='mapDiv'>河北地图热点效果5</div>");
  65. jq("#shanxi").TitleShow("<div class='mapDiv'>山西地图热点效果6</div>");
  66. jq("#neimenggu").TitleShow("<div class='mapDiv'>内蒙古地图热点效果7</div>");
  67. jq("#liaoning").TitleShow("<div class='mapDiv'>地图热点效果8</div>");
  68. jq("#jilin").TitleShow("<div class='mapDiv'>地图热点效果9</div>");
  69. jq("#heilongjiang").TitleShow("<div class='mapDiv'>黑龙江地图热点效果10</div>");
  70. jq("#jiangsu").TitleShow("<div class='mapDiv'>地图热点效果11</div>");
  71. jq("#zhejiang").TitleShow("<div class='mapDiv'>地图热点效果12</div>");
  72. jq("#anhui").TitleShow("<div class='mapDiv'>地图热点效果13</div>");
  73. jq("#fujian").TitleShow("<div class='mapDiv'>地图热点效果14</div>");
  74. jq("#jiangxi").TitleShow("<div class='mapDiv'>地图热点效果15</div>");
  75. jq("#shandong").TitleShow("<div class='mapDiv'>山东地图热点效果16</div>");
  76. jq("#henan").TitleShow("<div class='mapDiv'>河南地图热点效果17</div>");
  77. jq("#hubei").TitleShow("<div class='mapDiv'>湖北地图热点效果18</div>");
  78. jq("#hunan").TitleShow("<div class='mapDiv'>地图热点效果l9</div>");
  79. jq("#guangdong").TitleShow("<div class='mapDiv'>地图热点效果20e</div>");
  80. jq("#guangxi").TitleShow("<div class='mapDiv'>地图热点效果21</div>");
  81. jq("#hainan").TitleShow("<div class='mapDiv'>地图热点效果22</div>");
  82. jq("#sichuan").TitleShow("<div class='mapDiv'>地图热点效果23</div>");
  83. jq("#guizhou").TitleShow("<div class='mapDiv'>地图热点效果24</div>");
  84. jq("#yunnan").TitleShow("<div class='mapDiv'>地图热点效果25</div>");
  85. jq("#shaanxi").TitleShow("<div class='mapDiv'>地图热点效果26</div>");
  86. jq("#gansu").TitleShow("<div class='mapDiv'>地图热点效果27</div>");
  87. jq("#qinghai").TitleShow("<div class='mapDiv'>地图热点效果28</div>");
  88. jq("#ningxia").TitleShow("<div class='mapDiv'>宁夏地图热点效果29</div>");
  89. jq("#xinjiang").TitleShow("<div class='mapDiv'>新疆地图热点效果30</div>");
  90. jq("#xizang").TitleShow("<div class='mapDiv'>地图热点效果31</div>");
  91. jq("#xianggang").TitleShow("<div class='mapDiv'>香港地图热点效果32</div>");
  92. jq("#aomen").TitleShow("<div class='mapDiv'>地图热点效果33</div>");
  93. jq("#taiwan").TitleShow("<div class='mapDiv'>地图热点效果34</div>");
  94. });
  95. </script>
  96. <!--热点HTML代码开始 -->
  97. <div class="map">
  98. <img border="0" usemap="#Map" src="map.png" />
  99. <map name="Map" id="Map">
  100. <area id="beijing" alt="北京" href="#" coords="354,140,380,153" shape="rect">
  101. <area id="shanghai" alt="上海" href="#" coords="434,246,462,259" shape="rect">
  102. <area id="tianjin" alt="天津" href="#" coords="382,168,408,180" shape="rect">
  103. <area id="chongqing" alt="重庆" href="#" coords="294,264,320,276" shape="rect">
  104. <area id="hebei" alt="河北" href="#" coords="347,174,374,186" shape="rect">
  105. <area id="shanxi" alt="山西" href="#" coords="322,186,348,198" shape="rect">
  106. <area id="neimenggu" alt="内蒙古" href="#" coords="349,110,388,124" shape="rect">
  107. <area id="liaoning" alt="辽宁" href="#" coords="406,128,432,140" shape="rect">
  108. <area id="jilin" alt="吉林" href="#" coords="427,101,454,115" shape="rect">
  109. <area id="heilongjiang" alt="黑龙江" href="#" coords="424,58,464,73" shape="rect">
  110. <area id="jiangsu" alt="江苏" href="#" coords="404,224,417,250" shape="rect">
  111. <area id="zhejiang" alt="浙江" href="#" coords="413,265,427,291" shape="rect">
  112. <area id="anhui" alt="安徽" href="#" coords="382,236,395,263" shape="rect">
  113. <area id="fujian" alt="福建" href="#" coords="399,300,413,327" shape="rect">
  114. <area id="jiangxi" alt="江西" href="#" coords="371,286,385,313" shape="rect">
  115. <area id="shandong" alt="山东" href="#" coords="373,196,399,208" shape="rect">
  116. <area id="henan" alt="河南" href="#" coords="337,228,364,239" shape="rect">
  117. <area id="hubei" alt="湖北" href="#" coords="329,258,356,271" shape="rect">
  118. <area id="hunan" alt="湖南" href="#" coords="325,294,352,306" shape="rect">
  119. <area id="guangdong" alt="广东" href="#" coords="356,343,382,355" shape="rect">
  120. <area id="guangxi" alt="广西" href="#" coords="302,343,328,355" shape="rect">
  121. <area id="hainan" alt="海南" href="#" coords="313,398,340,411" shape="rect">
  122. <area id="sichuan" alt="四川" href="#" coords="239,265,265,277" shape="rect">
  123. <area id="guizhou" alt="贵州" href="#" coords="283,311,308,324" shape="rect">
  124. <area id="yunnan" alt="云南" href="#" coords="225,337,251,349" shape="rect">
  125. <area id="shaanxi" alt="陕西" href="#" coords="303,224,316,251" shape="rect">
  126. <area id="gansu" alt="甘肃" href="#" coords="179,156,205,168" shape="rect">
  127. <area id="qinghai" alt="青海" href="#" coords="174,206,200,218" shape="rect">
  128. <area id="ningxia" alt="宁夏" href="#" coords="277,188,290,212" shape="rect">
  129. <area id="xinjiang" alt="新疆" href="#" coords="85,140,111,152" shape="rect">
  130. <area id="xizang" alt="西藏" href="#" coords="87,249,113,261" shape="rect">
  131. <area id="xianggang" alt="香港" href="#" coords="379,358,406,370" shape="rect">
  132. <area id="aomen" alt="澳门" href="#" coords="349,371,375,383" shape="rect">
  133. <area id="taiwan" alt="台湾" href="#" coords="434,322,448,348" shape="rect">
  134. </map>
  135. </div>
  136. </body>
  137. </html>

以上所述就是本文的全部内容了,希望大家能够喜欢

人气教程排行