对话框/Tips

Tooltip 工具提示jQuery插件

阿里云


这是一款 jQuery Tooltip 工具提示插件。jTippy 工具提示插件简单灵活,提供多种触发 tooltip 的方式,并提供丰富的操作 api 和参数,非常实用。jTippy 工具提示插件的特点还有:

提供多种触发 tooltip 的方式:click, hover, focus, hoverfocus。

也想出现在这里?联系我们
创客主机

点击触发时,提供三种类型的遮罩层效果:合适、白色和模糊效果。

提供多种 tooltip 的主题:black, lt-gray, white, blue, green, red。

提供 tooltip 线索和隐藏的回调函数。

使用方法

在页面中引入 jquery 和 jTippy.min.js 文件,以及 jTippy.min.css 文件。

  1. <link rel="stylesheet" href="jTippy-master/jTippy.min.css">                  
  2. <script src="js/jquery.min.js" type="text/javascript"></script>
  3. <script src="js/jTippy.min..js"></script>

HTML 结构

最简单的使用方法如下,为一个超链接元素添加 title 属性,这个属性就是要显示的 tooltip 的内容:

  1. <a href='#'
  2.     data-toggle="tooltip"
  3.     title="提示的内容">
  4.     超链接
  5. </a>

初始化插件

在页面 DOM 元素加载完毕之后,通过下面的方法来初始化该 jQueryTooltip 工具提示插件。

  1. $(function(){
  2.   $('[data-toggle="tooltip"]').jTippy();
  3. });

配置参数

  1. $(function(){
  2.   $('[data-toggle="tooltip"]').jTippy({
  3.         //string: overridden by the title attribute
  4.         title: '',
  5.         //string ('click', 'hover', 'focus', 'hoverfocus'): defines when the tooltip should be shown
  6.         trigger: 'hoverfocus',
  7.         //string ('auto','top','bottom','left','right'): preferred location of the tooltip (defaults to auto if no space)
  8.         position: 'auto',
  9.         //string ('black', 'lt-gray', 'white', 'blue', 'green', 'red')
  10.         theme: 'black',
  11.         //string ('tiny', 'small', 'medium', 'large')
  12.         size: 'small',
  13.         //string|false ('black', 'white', 'blurred'): Only works with trigger: "click"
  14.         backdrop: false,
  15.         //string: class(es) to add to the tooltip
  16.         class: '',
  17.         //boolean: if true, when this tooltip is triggered, all others will hide
  18.         singleton: true,
  19.         //boolean: if true and trigger: 'click', when clicking outside the tooltip, it will be hidden
  20.         close_on_outside_click: true,
  21.   }).on('jt-show', function(e, tooltip){
  22.       //triggered on show of tooltip
  23.       //tooltip dom element is passed as the second parameter
  24.   }).on('jt-hide', function(e){
  25.       //triggered on hide of tooltip
  26.   });
  27. });

可以通过下面的语法来设置参数。

  1. $.jTippy.defaults.backdrop = false;
  2. $.jTippy.defaults.theme = 'black';
  3. $.jTippy.defaults.trigger = 'hoverfocus';

也可以通过在 html 上添加 data-*属性来设置参数。

  1. <a href='#'
  2.     data-toggle="tooltip"
  3.     data-backdrop="black"
  4.     data-trigger="click">
  5.     Black backdrop!
  6. </a>

Github 网址:Tooltip 工具提示插件

Tooltip 工具提示 jQuery 插件

已有 331 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!