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


Posted in Javascript onApril 18, 2016

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

运行效果截图如下:

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

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程序设计有所帮助。

Javascript 相关文章推荐
document.all与WEB标准
May 13 Javascript
javascript开发技术大全-第1章javascript概述
Jul 03 Javascript
JsDom 编程小结
Aug 09 Javascript
解决node-webkit 不支持html5播放mp4视频的方法
Mar 11 Javascript
jQuery定义背景动态切换效果的方法
Mar 23 Javascript
js电话号码验证方法
Sep 28 Javascript
javascript瀑布流布局实现方法详解
Feb 17 Javascript
原生JS和jQuery操作DOM对比总结
Jan 19 Javascript
js设置随机切换背景图片的简单实例
Nov 12 Javascript
Nuxt配合Node在实际生产中的应用详解
Aug 07 Javascript
Bootstrap Table列宽拖动的方法
Aug 15 Javascript
vue 实现用户登录方式的切换功能
Apr 14 Javascript
ArtEditor富文本编辑器增加表单提交功能
Apr 18 #Javascript
JS基于MSClass和setInterval实现ajax定时采集信息并滚动显示的方法
Apr 18 #Javascript
JS区分浏览器页面是刷新还是关闭
Apr 17 #Javascript
js组件SlotMachine实现图片切换效果制作抽奖系统
Apr 17 #Javascript
JS中取二维数组中最大值的方法汇总
Apr 17 #Javascript
JS组件Bootstrap ContextMenu右键菜单使用方法
Apr 17 #Javascript
js实现select二级联动下拉菜单
Apr 17 #Javascript
You might like
基于linnux+phantomjs实现生成图片格式的网页快照
2015/04/15 PHP
BOOM vs RR BO5 第四场 2.14
2021/03/10 DOTA
javascript URL锚点取值方法
2009/02/25 Javascript
JavaScript 学习笔记一些小技巧
2010/03/28 Javascript
iframe 上下滚动条如何默认在下方实现原理
2012/12/10 Javascript
js自定义方法通过隐藏iframe实现文件下载
2013/02/21 Javascript
如何使用jquery控制CSS样式,并且取消Css样式(如背景色,有实例)
2013/07/09 Javascript
JS+CSS实现一个气泡提示框
2013/08/18 Javascript
jQuery Mobile 和 Kendo UI 的比较
2016/05/05 Javascript
JavaScript语言精粹经典实例(整理篇)
2016/06/07 Javascript
浅谈js的url解析函数封装
2016/06/28 Javascript
轻松搞定js表单验证
2016/10/13 Javascript
bootstrap制作jsp页面(根据值让table显示选中)
2017/01/05 Javascript
深入理解Vue官方文档梳理之全局API
2017/11/22 Javascript
Vue中对比scoped css和css module的区别
2018/05/17 Javascript
对vue中v-on绑定自定事件的实例讲解
2018/09/06 Javascript
解决vue 引入子组件报错的问题
2018/09/06 Javascript
详解a标签添加onclick事件的几种方式
2019/03/29 Javascript
Vue实现剪切板图片压缩功能
2020/02/04 Javascript
Python中__name__的使用实例
2015/04/14 Python
Python远程桌面协议RDPY安装使用介绍
2015/04/15 Python
python实现向ppt文件里插入新幻灯片页面的方法
2015/04/28 Python
如何爬取通过ajax加载数据的网站
2019/08/15 Python
Python unittest单元测试openpyxl实现过程解析
2020/05/27 Python
Python生成器next方法和send方法区别详解
2020/05/30 Python
python使用matplotlib:subplot绘制多个子图的示例
2020/09/24 Python
python unichr函数知识点总结
2020/12/16 Python
仓库管理制度
2014/01/21 职场文书
销售经理岗位职责
2014/03/16 职场文书
事业单位绩效考核实施方案
2014/03/27 职场文书
机关会计岗位职责
2014/04/08 职场文书
重阳节活动总结
2014/08/27 职场文书
暑假安全教育广播稿
2014/09/10 职场文书
教师党员自我剖析材料
2014/09/29 职场文书
情侣餐厅的创业计划书范本!
2019/07/26 职场文书
使用Cargo工具高效创建Rust项目
2022/08/14 Javascript