jQuery实现鼠标跟随提示层效果代码(可显示文本,Div,Table,Html等)

 更新时间:2016年4月19日 10:00  点击:1436

本文实例讲述了jQuery实现鼠标跟随提示层效果代码。分享给大家供大家参考,具体如下:

运行效果截图如下:

Web网站有不少需要用到tip提示层的地方,结合jquery的jquery.cluetip.js ,可以实现本地字符或ajax异步调用显示提示层。如以上购评分明细提示。(优势:宽度需要调用页加载时定义,高度auto , 且三角指定图标能根据显示层的大小位置来调用它的位置,达到醒目直观的效果)

jquery.cluetip.css

/* global */
#cluetip-close img {
 border: 0;
}
#cluetip-title {
 overflow: hidden;
}
#cluetip-title #cluetip-close {
 float: right;
 position: relative;
}
#cluetip-waitimage {
 width: 43px;
 height: 11px;
 position: absolute;
 background-image: url(../img_new/cluetipwait.gif);
}
.cluetip-arrows {
 display: none;
 position: absolute;
 top: 0;
 left: -11px;
 height: 22px;
 width: 11px;
 background-repeat: no-repeat;
 background-position: 0 0;
}
#cluetip-extra {
 display: none;
}
/***************************************
  =cluetipClass: 'default' 
-------------------------------------- */
.cluetip-default {
 background-color: #d9d9c2;
}
.cluetip-default #cluetip-outer {
 position: relative;
 margin: 0;
 background-color: #d9d9c2;
}
.cluetip-default h3#cluetip-title {
 margin: 0 0 5px;
 padding: 8px 10px 4px;
 font-size: 14px;
 font-weight: normal;
 background-color: #87876a;
 color: #fff;
}
.cluetip-default #cluetip-title a {
 color: #d9d9c2;
 font-size: 0.95em;
} 
.cluetip-default #cluetip-inner {
 padding: 10px;
}
.cluetip-default div#cluetip-close { 
 text-align: right;
 margin: 0 5px 5px;
 color: #900;
}
/* default arrows */
.clue-right-default .cluetip-arrows {
 background-image: url(../img_new/cluetipdarrowleft.gif);
}
.clue-left-default .cluetip-arrows {
 background-image: url(../img_new/cluetipdarrowright.gif);
 left: 100%;
 margin-right: -11px;
}
.clue-top-default .cluetip-arrows {
 background-image: url(../img_new/cluetipdarrowdown.gif);
 top: 100%;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px; 
} 
.clue-bottom-default .cluetip-arrows {
 background-image: url(../img_new/cluetipdarrowup.gif);
 top: -11px;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px;
}
/***************************************
  =cluetipClass: 'jtip'
-------------------------------------- */
.cluetip-jtip {
 background-color: transparent;
  display:none;
}
.cluetip-jtip #cluetip-outer {
 border: 1px solid #559EF8;
 position: relative;
 background-color: #fff;
}
.cluetip-jtip h3#cluetip-title {
 margin: 0 0 5px;
 padding: 2px 5px;
 font-size: 12px;
 font-weight: normal;
 background-color: #559EF8;
 color: #fff; 
}
.cluetip-jtip #cluetip-inner {
 padding: 0 5px 5px;
 display: inline-block;
}
.cluetip-jtip div#cluetip-close { 
 text-align: right;
 margin: 0 5px 5px;
 color: #900; 
 display:none;
}
/* jtip arrows */
.clue-right-jtip .cluetip-arrows {
 background-image: url(../img_new/cluetiparrowleft.gif);
}
.clue-left-jtip .cluetip-arrows {
 background-image: url(../img_new/cluetiparrowright.gif);
 left: 100%;
 margin-right: -11px;
}
.clue-top-jtip .cluetip-arrows {
 background-image: url(../img_new/cluetiparrowdown.gif);
 top: 100%;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px; 
} 
.clue-bottom-jtip .cluetip-arrows {
 background-image: url(../img_new/cluetiparrowup.gif);
 top: -11px;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px;
}
/***************************************
  =cluetipClass: 'rounded'
-------------------------------------- */
.cluetip-rounded {
 background: transparent url(../img_new/cluetipbl.gif) no-repeat 0 100%;
 margin-top: 10px;
 margin-left: 12px;
}
.cluetip-rounded #cluetip-outer {
 background: transparent url(../img_new/cluetiptl.gif) no-repeat 0 0;
 margin-top: -12px;
}
.cluetip-rounded #cluetip-title {
 background-color: transparent;
 padding: 12px 12px 0;
 margin: 0 -12px 0 0;
 position: relative;
}
.cluetip-rounded #cluetip-extra {
 position: absolute;
 display: block;
 background: transparent url(../img_new/cluetiptr.gif) no-repeat 100% 0;
 top: 0;
 right: 0;
 width: 12px;
 height: 30px;
 margin: -12px -12px 0 0;
}
.cluetip-rounded #cluetip-inner {
 background: url(../img_new/cluetipbr.gif) no-repeat 100% 100%;
 padding: 5px 12px 12px;
 margin: -18px -12px 0 0;
 position: relative;
}
.cluetip-rounded div#cluetip-close { 
 text-align: right;
 margin: 0 5px 5px;
 color: #009;
 background: transparent;
}
.cluetip-rounded div#cluetip-close a {
 color: #777;
}
/* rounded arrows */
.clue-right-rounded .cluetip-arrows {
 background-image: url(../img_new/cluetiprarrowleft.gif);
}
.clue-left-rounded .cluetip-arrows {
 background-image: url(../img_new/cluetiprarrowright.gif);
 left: 100%;
 margin-left: 12px;
}
.clue-top-rounded .cluetip-arrows {
 background-image: url(../img_new/cluetiprarrowdown.gif);
 top: 100%;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px; 
} 
.clue-bottom-rounded .cluetip-arrows {
 background-image: url(../img_new/cluetiprarrowup.gif);
 top: -23px;
 left: 50%;
 margin-left: -11px;
 height: 11px;
 width: 22px;
}
/* stupid IE6 HasLayout hack */
.cluetip-rounded #cluetip-title,
.cluetip-rounded #cluetip-inner {
 zoom: 1;
}
.float-left {
 float: left;
 margin-right: .5em;
 display: inline;
 position: relative;
}
.float-right {
 float: right;
 margin-left: .5em;
 display: inline;
 position: relative;
}

jquery-1.3.2.min.js  -- 官方网可下载,这里不再表述。(必须)
jquerycluetipLoad.js  --提示层的基本参数和属性的定义。

/* Jquery 鼠标跟随提示层。
 * 创建人:fooo
 * 创建日期:09-09-23
 * 修改人:
 * 修改日期:
 * 本地字符提示示例:<span title="标题|<%=Str()%>"><a href="#" >我们的</a></span>
 * Ajax异步调用文件且提示示例:<ol><li><a class="jt" href="#" title="评分项目明细" rel="HandlerAjax.ashx?Name=<%=Security.EncryptQueryString("我们的我我我人大")%>" >clueTip - Ajax异步提示1</a> </li></ol>
 *
 * 改变提示层宽度大小,只需在调用页加入: $.fn.cluetip.defaults.width = '100'; -根据大小调整。
 */
 // $.fn.cluetip.defaults.tracking = true;
 // $.fn.cluetip.defaults.width = 'auto';
$(document).ready(function() 
{
 //default theme
 $('a.title').cluetip({splitTitle: '|'});
 $('a.basic').cluetip();
 $('a.custom-width').cluetip({width: '200px', showTitle: false});
 $('h4').cluetip({attribute: 'id', hoverClass: 'highlight'});
 $('#sticky').cluetip({sticky: true, closePosition: 'title', arrows: true });
 $('#examples a:eq(5)').cluetip({
  hoverClass: 'highlight',
  sticky: true,
  closePosition: 'bottom',
  closeText: '<img src="../img_new/cluetipcross.png" alt="close" width="16" height="16" />',
  truncate: 60
 });
 $('a.load-local').cluetip({local:true, hideLocal: true, sticky: true, arrows: true, cursor: 'pointer'});
 $('#clickme').cluetip({activation: 'click', sticky: true, width: 250});
 $('ol:first a:last').cluetip({tracking: true});
 //jTip theme
 $('a.jt:eq(0)').cluetip({
  cluetipClass: 'jtip', 
  arrows: true, 
  dropShadow: false,
  sticky: true,
  mouseOutClose: true,
  closePosition: 'title',
  closeText: '<img src="../img_new/cluetipcross.png" alt="close" />'
 });
 $('a.jt:eq(1)').cluetip({cluetipClass: 'jtip', arrows: true, dropShadow: false, hoverIntent: false});
 $('span[title]').css({borderBottom: '0px solid #900'}).cluetip({splitTitle: '|', arrows: true, dropShadow: false, cluetipClass: 'jtip'});
 $('a.jt:eq(2)').cluetip({
  cluetipClass: 'jtip', 
  arrows: true, 
  dropShadow: false, 
  height: '150px', 
  sticky: true,
  positionBy: 'bottomTop'  
 });
 $('a.jt:eq(3)').cluetip({local: true, hideLocal: false});
 $('a.jt:eq(4)').cluetip({
  cluetipClass: 'jtip', arrows: true, 
  dropShadow: false, 
  onActivate: function(e) {
   var cb = $('#cb')[0];
   return !cb || cb.checked;
  }
 });
// Rounded Corner theme
 $('ol.rounded a:eq(0)').cluetip({splitTitle: '|', dropShadow: false, cluetipClass: 'rounded', showtitle: false});
 $('ol.rounded a:eq(1)').cluetip({cluetipClass: 'rounded', dropShadow: false, showtitle: false, positionBy: 'mouse'});
 $('ol.rounded a:eq(2)').cluetip({cluetipClass: 'rounded', dropShadow: false, showtitle: false, positionBy: 'bottomTop', topOffset: 70});
 $('ol.rounded a:eq(3)').cluetip({cluetipClass: 'rounded', dropShadow: false, sticky: true, ajaxCache: false, arrows: true});
 $('ol.rounded a:eq(4)').cluetip({cluetipClass: 'rounded', dropShadow: false});  
});

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery日期与时间操作技巧总结》、《jQuery切换特效与技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》、《jquery选择器用法总结》及《jQuery常用插件及用法总结》

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

[!--infotagslink--]

相关文章

  • jquery实现加载更多"转圈圈"效果(示例代码)

    这篇文章主要介绍了jquery实现加载更多"转圈圈"效果,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-11-10
  • 自己动手写的jquery分页控件(非常简单实用)

    最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了。写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性...2015-10-30
  • jQuery+jRange实现滑动选取数值范围特效

    有时我们在页面上需要选择数值范围,如购物时选取价格区间,购买主机时自主选取CPU,内存大小配置等,使用直观的滑块条直接选取想要的数值大小即可,无需手动输入数值,操作简单又方便。HTML首先载入jQuery库文件以及jRange相关...2015-03-15
  • jQuery实现非常实用漂亮的select下拉菜单选择效果

    本文实例讲述了jQuery实现非常实用漂亮的select下拉菜单选择效果。分享给大家供大家参考,具体如下:先来看如下运行效果截图:在线演示地址如下:http://demo.jb51.net/js/2015/js-select-chose-style-menu-codes/具体代码如...2015-11-08
  • jquery实现的伪分页效果代码

    本文实例讲述了jquery实现的伪分页效果代码。分享给大家供大家参考,具体如下:这里介绍的jquery伪分页效果,在火狐下表现完美,IE全系列下有些问题,引入了jQuery1.7.2插件,代码里有丰富的注释,相信对学习jQuery有不小的帮助,期...2015-10-30
  • Jquery Ajax Error 调试错误的技巧

    JQuery使我们在开发Ajax应用程序的时候提高了效率,减少了许多兼容性问题,我们在Ajax项目中,遇到ajax异步获取数据出错怎么办,我们可以通过捕捉error事件来获取出错的信息。在没给大家介绍正文之前先给分享Jquery中AJAX参...2015-11-24
  • jQuery 2.0.3 源码分析之core(一)整体架构

    拜读一个开源框架,最想学到的就是设计的思想和实现的技巧。废话不多说,jquery这么多年了分析都写烂了,老早以前就拜读过,不过这几年都是做移动端,一直御用zepto, 最近抽出点时间把jquery又给扫一遍我也不会照本宣科的翻译...2014-05-31
  • jQuery页面加载初始化常用的三种方法

    当页面打开时我们需要执行一些操作,这个时候如果我们选择使用jquery的话,需要重写他的3中方法,自我感觉没什么区 别,看个人喜好了,第二种感觉比较简单明了: 第一种: 复制代码 代码如下: <script type="text/javas...2014-06-07
  • jquery中常用的SET和GET$(”#msg”).html循环介绍

    复制代码 代码如下: $(”#msg”).html(); //返回id为msg的元素节点的html内容。 $(”#msg”).html(”new content“); //将“new content” 作为html串写入id为msg的元素节点内容中,页面显示粗体的new content $(”...2013-10-13
  • jquery获取div距离窗口和父级dv的距离示例

    jquery中jquery.offset().top / left用于获取div距离窗口的距离,jquery.position().top / left 用于获取距离父级div的距离(必须是绝对定位的div)。 (1)先介绍jquery.offset().top / left css: 复制代码 代码如下: *{ mar...2013-10-13
  • jQuery Mobile开发中日期插件Mobiscroll使用说明

    这篇文章主要介绍了jQuery Mobile开发中日期插件Mobiscroll使用说明,需要的朋友可以参考下...2016-03-03
  • jQuery实现切换页面过渡动画效果

    直接为大家介绍制作过程,希望大家可以喜欢。HTML结构该页面切换特效的HTML结构使用一个<main>元素来作为页面的包裹元素,div.cd-cover-layer用于制作页面切换时的遮罩层,div.cd-loading-bar是进行ajax加载时的loading进...2015-10-30
  • jQuery实现鼠标滑过链接控制图片的滑动展开与隐藏效果

    本文实例讲述了jQuery实现鼠标滑过链接控制图片的滑动展开与隐藏效果。分享给大家供大家参考,具体如下:这里演示jQuery实现鼠标移动到链接上,滑动展开/隐藏图片效果,鼠标放在“上一页”“下一页”上,立即浮现出所对应的图...2015-10-30
  • jQuery+PHP发布的内容进行无刷新分页(Fckeditor)

    这篇文章将使用jQuery,并结合PHP,将Fckeditor发布的内容进行分页,并且实现无刷新切换页面。 本文假设你是WEB开发人员,掌握了jQuery和PHP相关知识,并且熟知Fckeditor的配置和使用。...2015-10-23
  • jQuery实现带玻璃流光质感的手风琴特效

    jQuery实现带玻璃流光质感的手风琴特效是一款基于jQuery+CSS3实现的带玻璃流光质感的手风琴特效,分享给大家,具体如下效果图:具体代码如下:html代码: <section class="strips"> <article class="strips__strip"> <di...2015-11-24
  • 使用JQuery实现Ctrl+Enter提交表单的方法

    有时候我们为了省事就操作键盘组合键去代替使用鼠标,我们今天就使用JQuery实现Ctrl+Enter提交表单。我们发帖时,在内容输入框中输入完内容后,可以点击“提交”按钮来发表内容。可是,如果你够“懒”,你可以不用动鼠标,只需按...2015-10-23
  • jQuery 1.9使用$.support替代$.browser的使用方法

    jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support 。 在更新的 2.0 版本中,将不再支持 IE 6/7/8。 以后,如果用户需要支持 IE 6/7/8,只能使用 jQuery 1.9。 如果要全面支持 IE,并混合...2014-05-31
  • jQuery+slidereveal实现的面板滑动侧边展出效果

    我们借助一款jQuery插件:slidereveal.js,可以使用它控制面板左右侧滑出与隐藏等效果,项目地址:https://github.com/nnattawat/slideReveal。如何使用首先在页面中加载jquery库文件和slidereveal.js插件。复制代码 代码如...2015-03-15
  • jquery validate demo 基础

    jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求。该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自...2015-10-30
  • jQuery 中的 DOM 操作

    在DOM操作中,常常需要动态创建HTML内容,使文档在浏览器里的呈现效果发生变化,并且达到各种各样的人机交互目的....2016-04-27