制作jQuery文字提示插件
(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'});
})
<li><a href="#" title="提示内容">标题
<span class="colorTip" style="margin-left:-60px;">提示内容
<span class="pointyTipShadow"></span>
<span class="pointyTip"></span>
</span>
</a></li>
制作jQuery文字提示插件的更多相关文章
- 在Eclipse中制作SSH配置文件提示插件
原文地址:http://blog.csdn.net/longyuhome/article/details/8968093 这篇博客算是对原先的“在Eclipse中制作和使用struts2配置文件提示插 ...
- 漂亮灵活设置的jquery通知提示插件toastr
toastr是一款非常棒的基于jquery库的非阻塞通知提示插件,toastr可设定四种通知模式:成功,出错,警告,提示,而提示窗口的位置,动画效果都可以通过能数来设置,在官方站可以通过勾选参数来生成 ...
- PoshyTip jQuery 文本提示插件的使用
PoshyTip 是JQuery中一款文本提示插件,在Jsp页面使用相当方便,插件内包含了很多外观样式,可以作为FormTooltips使用. 插件包下载地址:http://vadikom.com/f ...
- Jquery消息提示插件toastr使用详解
toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 1.使用很简单,首选引入toastr的js.css文件 html <script s ...
- Jquery消息提示插件toastr使用
toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 相关文件到官网去下载即可 1.引入toastr的js和css文件 <link hre ...
- Jquery 错误提示插件
这是一个简单的输入框错误提示插件,可拓展! .jq-error{ font-size:12px; min-width:150px; width:auto; max-width:350px; line- ...
- Jquery消息提示插件toastr
toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 1.使用很简单,首选引入toastr的js.css文件 <script src=&q ...
- 介绍Web项目中用到的几款JQuery消息提示插件
第一款 noty 官方网站:https://github.com/needim/noty 第二款 artDialog artDialog是一个精巧的web对话框组件,压缩后只有十多KB,并且不依赖其他 ...
- 推荐10个超棒的jQuery工具 提示插件
脚本之家 http://www.jb51.net/article/28525.htm
随机推荐
- Beand的高级特征
Spring程序中,Java Bean一般与Spring是非耦合的,不会依赖于Spring类库.这也是Spring的优点. 实现BeanNameAware接口获取本bean的id属性 BeanName ...
- [翻译]HTTP: Let’s GET It On!
原文地址:HTTP: Let’s GET It On! 简介 几周之前,我们了解到HTTP是一个应用级的协议.现在是时候探索我们应该如何在客户端和服务端的通信之间使用这个协议了. 从网络上获取资源 记 ...
- Enlish E-mail approve skills
for example 2Per our T/C, pls send me the schematic of 035342 & mark the deviation for C3 so I c ...
- 网页瀑布流布局插件Masonry
CSS3有实现类似瀑布流布局的属性column,但是遗憾的是这种布局是纵向布局而不支持横向布局.所以比较合适用于文字多列布局. 调用JQuery WaterFall布局插件:http://masonr ...
- linux平台模拟生成CAN设备
前言 使用socketCan的过程中有时候没有can接口设备,但是需要测试一下can接口程序是否有问题, 此时需要系统模拟生成can设备,本文介绍linux平台模拟生成CAN设备的方法. 实现步骤 1 ...
- mysql完整版
mysql: dbs 数据库系统 bdms 数据库管理系统 bda 数据库管理员 db 数据库 dba通过dbms来操作db! 关系型数据库和非关系型数据库 登录mysql mysql -h主机地址 ...
- 写个简单的chrome插件-京东商品历史价格查询
说chrome插件编写的先关文章, 首推小茗的[干货]Chrome插件(扩展)开发全攻略. 有非常完善的理论,引用和demo代码. 但是还是建议看官方的 chrome extensions. chro ...
- HDMI接口基本信息
一.HDMI基本概念1.HDMI标准的发展历史: 2002年12月9日,HDMI1.0版正式发布,标志着HDMI技术正式登上历史舞台. 2004年1月,HDMI1.1版发布. 2005年8月,HDMI ...
- PowerCollections
Wintellect 的Power collections 库 BigList<String> str = new BigList<String>(); str.Add(&qu ...
- Java的四种引用之强弱软虚
在java中提供4个级别的引用:强引用.软引用.弱引用和虚引用.除了强引用外,其他3中引用均可以在java.lang.ref包中找到对应的类.开发人员可以在应用程序中直接使用他们. 1 强引用 强引用 ...