jquery实现简单文字提示效果

2019-12-17,,,

本文实例讲述了jquery实现简单文字提示效果。分享给大家供大家参考,具体如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery实现简单文字提示</title>
<style type="text/css">
#preview{border:2px solid #c7c7c7; background:#e3f4f9; padding:5px; display:none; position:absolute;}
</style>
<script src="jquery-1.2.6.pack.js" type="text/javascript"></script>
</head>
<body>
<a class="preview" title="看看提示出现了没">移到我身上来!!</a>
<script type="text/javascript">
this.imagePreview = function(){ 
/* CONFIG */
  xOffset = 10;
  yOffset = 20;
  // 可以自己设定偏移值
/* END CONFIG */
$("a.preview").hover(function(e){
  this.t = this.title;
  this.title = ""; 
  var c = (this.t != "") ? "" + this.t : "";
  $("body").append("<div id='preview'>"+ c +"</div>");     
  $("#preview")
  .css("top",(e.pageY - xOffset) + "px")
  .css("left",(e.pageX + yOffset) + "px")
  .fadeIn("fast");   
  },
function(){
  this.title = this.t; 
  $("#preview").remove();
  }); 
$("a.preview").mousemove(function(e){
  $("#preview")
  .css("top",(e.pageY - xOffset) + "px")
  .css("left",(e.pageX + yOffset) + "px");
});  
};
// 页面加载完执行
$(document).ready(function(){
imagePreview();
});
</script>
</body>
</html>

jquery-1.2.6.pack.js插件点击此处本站下载。

希望本文所述对大家jQuery程序设计有所帮助。

您可能感兴趣的文章:

  • JQuery实现超链接鼠标提示效果的方法
  • jquery实现网站超链接和图片提示效果
  • jQuery简单实现title提示效果示例
  • jQuery文字提示与图片提示效果实现方法
  • jQuery实现仿QQ空间装扮预览图片的鼠标提示效果代码
  • jquery实现鼠标滑过后动态图片提示效果实例
  • jQuery实现行文字链接提示效果的方法
  • jquery删除数据记录时的弹出提示效果
  • jQuery表单获取和失去焦点输入框提示效果的实例代码
  • jQuery实现的超链接提示效果示例【附demo源码下载】

《jquery实现简单文字提示效果.doc》

下载本文的Word格式文档,以方便收藏与打印。