(functions($){

$.fn.colorTip=function(settings){
var defaultSettings={
color:'yellow',
timeout:500
}
var supportedColor=['red','green','blue','white','yellow','black'];
settings=$.extend(defaultSettings);
return this.each(function(){
var elem=$(this);
if(!elem.attr('title')) return true;
var scheduleEvent=new eventScheduler();
var tip=new Tip(elem.attr('title'));
elem.append(tip.generate()).addClass('colorTipContainer');
var hasClass=false;
for(var i=0;i<supportedColors.length;i++){
if(elem.hasClass(supportedColor[i])){
hasClass=true;
break;
}
}
if(!hasClass){
elem.addClass(settings.color);
}
elem.hover(function(){
tip.show();
scheduleEvent.clear();
},function(){
scheduleEvent.set(function(){
tip.hide();
},settings.timeout);
});
elem.removeAttr('title');
});
}
function eventScheduler(){}
eventScheduler.prototype={
set:function(func,timeout){
this.timer=setTimeout(func,timeout);
},
clear:function(){
clearTimeout(this.timer);
}
}
function Tip(txt){
this.content=txt;
this.shown=false;
}
Tip.prototype={
generate:function(){
return this.tip||(this.tip=$('span class="colorTip">'+this.content+'<span class="pointyTipShadow"></span><span class="pointyTip"></span></span>'));
},
show:function(){
if(this.shown) return;
this.tip.css('margin-left',-this.tip.outerWidth()/2.fadeIn('fast'));
this.shown=true;
},
hide:function(){
this.tip.fadeOut();
this.shown=false;
}
}
})(jQuery); $(function(){
$('[title]').colorTip({color:'yellow'});
})
 
html
<li><a href="#" title="提示内容">标题
<span class="colorTip" style="margin-left:-60px;">提示内容
<span class="pointyTipShadow"></span>
<span class="pointyTip"></span>
</span>
</a></li>

制作jQuery文字提示插件的更多相关文章

  1. 在Eclipse中制作SSH配置文件提示插件

    原文地址:http://blog.csdn.net/longyuhome/article/details/8968093 这篇博客算是对原先的“在Eclipse中制作和使用struts2配置文件提示插 ...

  2. 漂亮灵活设置的jquery通知提示插件toastr

    toastr是一款非常棒的基于jquery库的非阻塞通知提示插件,toastr可设定四种通知模式:成功,出错,警告,提示,而提示窗口的位置,动画效果都可以通过能数来设置,在官方站可以通过勾选参数来生成 ...

  3. PoshyTip jQuery 文本提示插件的使用

    PoshyTip 是JQuery中一款文本提示插件,在Jsp页面使用相当方便,插件内包含了很多外观样式,可以作为FormTooltips使用. 插件包下载地址:http://vadikom.com/f ...

  4. Jquery消息提示插件toastr使用详解

    toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 1.使用很简单,首选引入toastr的js.css文件 html <script s ...

  5. Jquery消息提示插件toastr使用

    toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 相关文件到官网去下载即可 1.引入toastr的js和css文件 <link hre ...

  6. Jquery 错误提示插件

    这是一个简单的输入框错误提示插件,可拓展! .jq-error{ font-size:12px; min-width:150px; width:auto; max-width:350px; line- ...

  7. Jquery消息提示插件toastr

    toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 1.使用很简单,首选引入toastr的js.css文件 <script src=&q ...

  8. 介绍Web项目中用到的几款JQuery消息提示插件

    第一款 noty 官方网站:https://github.com/needim/noty 第二款 artDialog artDialog是一个精巧的web对话框组件,压缩后只有十多KB,并且不依赖其他 ...

  9. 推荐10个超棒的jQuery工具 提示插件

    脚本之家 http://www.jb51.net/article/28525.htm

随机推荐

  1. android开源项目集合

    ZXing http://code.google.com/p/zxing/ 条形码.二维码 K-9 Mail http://code.google.com/p/k9mail/ 邮件客户端 Sipdro ...

  2. ORACLE telnet 1521 不通及ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务的解决

    服务器上安装了oracle11g , 防火墙上已经增加1521 入站规则.但是内网客户端配置好了TNS无法连接.telnet 1521 不通. 需要在服务器上\product\10.2.0\db_1\ ...

  3. avalon源码阅读(1)

    来源 写angularJS源码阅读系列的时候,写的太垃圾了. 一个月后看,真心不忍直视,以后有机会的话得重写. 这次写avalonJS,希望能在代码架构层面多些一点,少上源码.多写思路. avalon ...

  4. UNIX设备文件

    UNIX和Linux中比较重要的三个设备文件是:/dev/console,/dev/tty和/dev/null. 0 /dev/console 这个设备代表的是系统控制台,错误信息和诊断信息通常会被发 ...

  5. VC++ 6.0 C8051F340 USB PC侧通信 Demo

    // HelloWorld.cpp : Defines the entry point for the console application. // /*********************** ...

  6. Linux C socket 封装

    /************************************************************************** * Linux C socket 封装 * 声明 ...

  7. BZOJ4475: [Jsoi2015]子集选取【找规律】【数学】

    Description Input 输入包含一行两个整数N和K,1<=N,K<=10^9 Output 一行一个整数,表示不同方案数目模1,000,000,007的值. Sample In ...

  8. jsp之response方法

    response简介 response对象:对客户端的请求作出回应,将Web服务器处理后的结果发回客户端. response对象:属于javax.servlet.HttpServletResponse ...

  9. 《DSP using MATLAB》Problem 3.5

    定义为: 如果序列绝对可和,其DTFT就存在.

  10. hdu1233 还是畅通工程 最小生成树

    给出修建边的边权,求连通所有点的最小花费 最小生成树裸题 #include<stdio.h> #include<string.h> #include<algorithm& ...