国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能示例

Original 2017-01-07 15:15:28 302
abstract:本文實(shí)例講述了jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能的方法。分享給大家供大家參考,具體如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1

本文實(shí)例講述了jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能的方法。分享給大家供大家參考,具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題頁(yè)</title>
<script type="text/javascript" src="jquery-1.4.2.min.js" ></script>
<script type="text/javascript">
  function ShowTip(event,obj,message)
  {
   var xOffset = -10; // x distance from mouse
   var yOffset = 10; // y distance from mouse
   //obj.style.top = (event.clientX + yOffset)+"px";
   //obj.style.left = (event.clientY + xOffset)+"px";
   //獲取元素width: $(obj).width();
   //獲取元素height:$(obj).height()
   //獲取元素位置:$(obj).position().top和$(obj).offset().top
   $('body').append( '<div id="tipmessage">'+message+'</div>');
   $('div#tipmessage').css("top", $(obj).position().top+$(obj).height() + "px").css("left", $(obj).position().left+"px").fadeIn("slow");
  }
  function HideTip()
  {
   $("div#tipmessage").fadeOut("slow").remove();
  }
 </script>
 <style type="text/css">
  #tipmessage
  {
  display:none;
  z-index:1000;
  border:1px solid #448833;
  position:absolute;
  background:#ffffff;
  max-width:200px;
  max-height:30px;
  padding:5px 10px;
  }
</style>
</head>
<body>
<a href="#" onmouseover="ShowTip(event,this,'歡迎訪問PHP中文網(wǎng)')" onmouseout="HideTip()">Tip</a>
</body>
</html>

更多關(guān)于jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能示例請(qǐng)關(guān)注PHP中文網(wǎng)(m.miracleart.cn)其他文章! 

Release Notes

Popular Entries