制作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
随机推荐
- JAVA第5次作业
将指定目录下的所有文件显示到列表框(JList)组件中,如下图所示: import java.awt.BorderLayout; import java.awt.Color; import java. ...
- SWIFT中使用AFNetwroking访问网络数据
AFNetworking 是 iOS 一个使用很方便的第三方网络开发框架,它可以很轻松的从一个URL地址内获取JSON数据. 在使用它时我用到包管理器Cocoapods 不懂的请移步: Cocoapo ...
- UI基础:UITableView表视图
表视图 UITableView,iOS中最重要的视图,随处可见. 表视图通常用来管理一组具有相同数据结构的数据. UITableView继承于UIScrollView,所以可以滚动 表视图的每条数据都 ...
- Spring的事件发布机制
一:Spring的事件发布 ApplicationContext提供了针对Bean的事件传播功能,其中的主角是publishEvent()方法,通过这个方法可以将事件通知给系统内的监听器(需实现App ...
- rabbitmq学习(五):springboot整合rabbitmq
一.Springboot对rabbitmq的支持 springboot提供了对rabbitmq的支持,并且大大简化了rabbitmq的相关配置.在springboot中,框架帮我们将不同的交换机划分出 ...
- Maze dfs倒行
Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or i ...
- 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.1 规则文件
转载至:https://blog.csdn.net/wo541075754/article/details/75150267 一个标准的规则文件的格式为已“.drl”结尾的文本文件,因此可以通过记事本 ...
- php header运用细节
http://www.111cn.net/phper/php-function/55872.htm http://blog.sina.com.cn/s/blog_7298f36f01011dxv.ht ...
- SharedImageCollection
https://documentation.devexpress.com/#WindowsForms/clsDevExpressUtilsSharedImageCollectiontopic The ...
- net web service 参数类型
因为Web Services的执行是建立在XML架构之上的,所以它能够支持丰富的数据类型. 下表列出了使用SOAP协议时Web Services支持的数据类型: 类 型 含 义 基础类型 也即标准基 ...