jquery的Tooltip插件 qtip使用详细说明


Posted in Javascript onSeptember 08, 2010

例如:
Internet Explorer 6.0+
Firefox 2.0+
Opera 9.0+
Safari 3.0+
Google Chrome 1.0+
Konqueror 3.5+
使用qTip可以很轻松的定义tip的位置以及样式,同时qTip还有一个强大的API......
使用qTip前,只需引入两个JS文件即可:

<script type="text/javascript" src="jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="jquery.qtip-1.0.0-rc3.min.js"></script>

下面举几个比较简单的例子。

1、Basic text

html如下所示:

<div id="content"> 
<a href=" ">Basic text</a> 
</div>

JS代码:
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('#content a[href]').qtip( 
{ 
content: 'Some basic content for the tooltip' 
}); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
2、Title attribute

html如下所示:

<div id="content"> 
<a href=" " title="That sounds familiar...">Title attribute</a> 
</div>

JS代码:
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('#content a[href][title]').qtip({ 
content: { 
text: false 
}, 
style: 'cream' 
}); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
3、Image

html如下所示:
<div id="content"> 
<a href=" ">Image</a> 
</div>

JS代码:
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('#content a[href]').qtip({ 
content: '<img src="small.png" alt="Image" />' 
}); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
4、Corner values

html如下所示:

<div id="content" style="margin-top:200px;margin-left:200px;"> 
<a href=" ">Corner values</a> 
</div>

JS代码:
<script type="text/javascript"> 
var corners = 'bottomLeft'; 
var opposites = 'topRight'; 
$(document).ready(function() 
{ 
$('#content a') 
.hover(function() 
{ 
$(this).html(opposites) 
.qtip({ 
content: corners, 
position: { 
corner: { 
tooltip: corners, 
target: opposites 
} 
}, 
show: { 
when: false, 
ready: true 
}, 
hide: false, 
style: { 
border: { 
width: 5, 
radius: 10 
}, 
padding: 10, 
textAlign: 'center', 
tip: true, 
name: 'cream' 
} 
}); 
}); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
5、Fixed tooltips

html如下所示:
<div id="content"> 
<img src="sample.jpg" alt="" height="200" /> 
</div>

JS代码:
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('#content img').each(function() 
{ 
$(this).qtip( 
{ 
content: '<a href=" ">Edit</a> | <a href=" ">Delete</a>', 
position: 'topRight', 
hide: { 
fixed: true 
}, 
style: { 
padding: '5px 15px', 
name: 'cream' 
} 
}); 
}); 
}); 
</script>

css代码:
<style type="text/css"> 
#content img{ 
float: left; 
margin-right: 35px; 
border: 2px solid #454545; 
padding: 1px; 
} 
</style>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
6、Loading html

html如下所示:
<div id="content"> 
<a href="#" rel="sample.html">Click me</a> 
</div>

JS代码:
Js代码 
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('#content a[rel]').each(function() 
{ 
$(this).qtip( 
{ 
content: { 
url: $(this).attr('rel'), 
title: { 
text: 'Wiki - ' + $(this).text(), 
button: 'Close' 
} 
}, 
position: { 
corner: { 
target: 'bottomMiddle', 
tooltip: 'topMiddle' 
}, 
adjust: { 
screen: true 
} 
}, 
show: { 
when: 'click', 
solo: true 
}, 
hide: 'unfocus', 
style: { 
tip: true, 
border: { 
width: 0, 
radius: 4 
}, 
name: 'light', 
width: 570 
} 
}) 
}); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
7、Modal tooltips
html如下所示:
<div id="content"> 
<a href="#" rel="modal">Click here</a> 
</div>

JS代码:
<script type="text/javascript"> 
$(document).ready(function() 
{ 
$('a[rel="modal"]:first').qtip( 
{ 
content: { 
title: { 
text: 'Modal tooltips sample', 
button: 'Close' 
}, 
text: 'hello world' 
}, 
position: { 
target: $(document.body), 
corner: 'center' 
}, 
show: { 
when: 'click', 
solo: true 
}, 
hide: false, 
style: { 
width: { max: 350 }, 
padding: '14px', 
border: { 
width: 9, 
radius: 9, 
color: '#666666' 
}, 
name: 'light' 
}, 
api: { 
beforeShow: function() 
{ 
$('#qtip-blanket').fadeIn(this.options.show.effect.length); 
}, 
beforeHide: function() 
{ 
$('#qtip-blanket').fadeOut(this.options.hide.effect.length); 
} 
} 
}); 
$('<div id="qtip-blanket">') 
.css({ 
position: 'absolute', 
top: $(document).scrollTop(), 
left: 0, 
height: $(document).height(), 
width: '100%', 
opacity: 0.7, 
backgroundColor: 'black', 
zIndex: 5000 
}) 
.appendTo(document.body) 
.hide(); 
}); 
</script>

效果如图所示:
jquery的Tooltip插件 qtip使用详细说明
Javascript 相关文章推荐
JavaScript中继承的一些示例方法与属性参考
Aug 07 Javascript
JavaScript中变量提升 Hoisting
Jul 03 Javascript
ajax异步刷新实现更新数据库
Dec 03 Javascript
防止浏览器记住用户名及密码的简单实用方法
Apr 22 Javascript
使用jquery菜单插件HoverTree仿京东无限级菜单
Dec 18 Javascript
jQuery实现仿腾讯视频列表分页效果的方法
Aug 07 Javascript
zTree插件下拉树使用入门教程
Apr 11 Javascript
vue的无缝滚动组件vue-seamless-scroll实例
Dec 18 Javascript
vue中Axios的封装与API接口的管理详解
Aug 09 Javascript
适合前端Vue开发童鞋的跨平台Weex的使用详解
Oct 16 Javascript
vue父子组件的通信方法(实例详解)
Nov 10 Javascript
vuex的数据渲染与修改浅析
Nov 26 Vue.js
jquery的Theme和Theme Switcher使用小结
Sep 08 #Javascript
复制小说文本时出现的随机乱码的去除方法
Sep 07 #Javascript
extjs grid设置某列背景颜色和字体颜色的实现方法
Sep 06 #Javascript
动态加载图片路径 保持JavaScript控件的相对独立性
Sep 06 #Javascript
Document对象内容集合(比较全)
Sep 06 #Javascript
Jquery优化效率 提升性能解决方案
Sep 06 #Javascript
jquery中this的使用说明
Sep 06 #Javascript
You might like
SONY SRF-40W电路分析
2021/03/02 无线电
检查url链接是否已经有参数的php代码 添加 ? 或 &amp;
2010/02/09 PHP
解决Laravel无法使用COOKIE和SESSION的问题
2019/10/16 PHP
laravel 框架实现无限级分类的方法示例
2019/10/31 PHP
javascript FormatNumber函数实现方法
2008/12/30 Javascript
Chrome Form多次提交表单问题的解决方法
2011/05/09 Javascript
用JQuery模仿淘宝的图片放大镜显示效果
2011/09/15 Javascript
初识SmartJS - AOP三剑客
2014/06/08 Javascript
jQuery学习笔记之jQuery中的$
2015/01/19 Javascript
js实现非常简单的焦点图切换特效实例
2015/05/07 Javascript
canvas绘制一个常用的emoji表情
2017/03/30 Javascript
jQuery pagination分页示例详解
2018/10/23 jQuery
微信小程序如何实现点击图片放大功能
2020/01/21 Javascript
微信小程序自定义navigationBar顶部导航栏适配所有机型(附完整案例)
2020/04/26 Javascript
Vue elementui字体图标显示问题解决方案
2020/08/18 Javascript
[02:32]DOTA2亚洲邀请赛 C9战队出场宣传片
2015/02/07 DOTA
Python中最常用的操作列表的几种方法归纳
2015/04/24 Python
详解python发送各类邮件的主要方法
2016/12/22 Python
Python IDLE清空窗口的实例
2018/06/25 Python
Python连接Mssql基础教程之Python库pymssql
2018/09/16 Python
python计算阶乘和的方法(1!+2!+3!+...+n!)
2019/02/01 Python
python matplotlib画图库学习绘制常用的图
2019/03/19 Python
Django Python 获取请求头信息Content-Range的方法
2019/08/06 Python
python时间日期操作方法实例小结
2020/02/06 Python
解决Tensorboard可视化错误:不显示数据 No scalar data was found
2020/02/15 Python
简单了解Java Netty Reactor三种线程模型
2020/04/26 Python
5分钟让你掌握css3阴影、倒影、渐变小技巧(小编推荐)
2016/08/15 HTML / CSS
AmazeUI在模态框中嵌入表单形成模态输入框
2020/08/20 HTML / CSS
美国指甲油品牌:Deco Miami
2017/01/30 全球购物
巴西香水和化妆品购物网站:The Beauty Box
2019/09/03 全球购物
SQL数据库笔试题
2016/03/08 面试题
毕业生的自我鉴定该怎么写
2013/12/02 职场文书
人身损害赔偿协议书格式
2014/11/01 职场文书
考试作弊检讨
2015/01/27 职场文书
python3使用diagrams绘制架构图的步骤
2021/04/08 Python
SQLServer常见数学函数梳理总结
2022/08/05 MySQL