制作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
随机推荐
- 利用InstallShiled 10.5制作AE应用程序安装包
[转]利用InstallShiled 10.5制作AE应用程序安装包 作者:3SNEWS 社区ESRI(ArcGIS)版版主:zhaoxiang_whuhttp://www.3snews.net/bb ...
- AVG Internet Security 2013 – 免费1年
AVG 是一款来自捷克的老牌的且非常优秀的免费杀毒软件,自推出以来就颇受用户好评!一直以来诸多的优点使其获得不少忠实用户,即便在中国也赢得了不少粉丝!AVG的安全产品广泛地被欧美以及大洋洲地区使用,并 ...
- 根据redis的pub/sub机制,写一个即时在线聊天应用
在Redis中,有个Pub/Sub,他的主要的工作流程如: redis订阅一个模式频道如:chat_*,然后由小a想找人聊天了,就发送一个消息“现在有人聊天吗?chat_a”,末尾的chat_a为标识 ...
- SharePoint Foundation 搜索-PowerShell
1. 显示搜索服务信息 Get-SPSearchService 2. 显示搜索服务实例 Get-SPSearchServiceInstance 3. 获取指定搜索服务实例 $ssInstance = ...
- ZOJ2540 Form a Square
Form a Square 题意就是 判断 给你四个点,能否组成一个正方形 要点: 格式很重要, 很重要!!! 数据很小,直接暴力 四个点判断是否为正方形,只需将所有可能的边长度算出来,然后选其中最短 ...
- select into from和insert into from
最近在研究oracle function 时发现select into from和insert into from,这样的语句,于是上网查阅资料学习了一下, 原来两种表达式均可以达到复制整个表或表的一 ...
- Python学习(004)-字典{}
特点: 无序状态 键唯一 不可变类型:字符串.整型.元组 可变类型:列表.字典 字典创建 第一种: dic1={','sex':'man'} print(dic1['name']) ----- ...
- iOS 工程自动化 - OCLint
前言 最近一直在做 iOS 工程自动化方向的事情,所以把自己研究和实践的内容进行记录并分享,希望能给大家一些帮助. 为什么要使用 OCLint 做为一个静态代码分析工具,我们引入 OCLint 的目的 ...
- 解决tensorflow的"Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Using TensorFlow backend."警告问题
问题描述 程序开始运行的时候报出警告:I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructio ...
- 会声会影X7安装不了,总是提示已经安装其他版本,怎么办
会声会影X7安装不了,总是提示已经安装其他版本,怎么办 卸载c++2008,安装会声会影,ok. 卸载工具:Windows Install Clean Up