mouseenter和mouseout中间的时间控制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title></title> </head>
<body> <div id="test" style="border: 1px solid #CCC; width: 100px; height: 100px; background: #666;">这是一个测试DIV
把鼠标放在上面2秒后会弹出他的ID</div>
<script type="text/javascript">
// <![CDATA[
var delay=function(t,fn){
var i=0,
j=10,
t=(t*1000)/j,
//把延迟时间平均分成10等份
_this=this,
//解决this绑定问题,所以调用delay函数的时候,请处理好this指向本身对象
d=setInterval(function(){
i++;
if(i==j){
clearInterval(d);
fn.apply(_this);
};
},t); _this.onmouseout=function(){
clearInterval(d);
}; }
document.getElementById("test").onmouseover=function(){
delay.apply(this,[2,function(){
alert(this.id)
}]);
//使用apply改变this指针
};
// ]]>
</script> </body>
</html>
$(".a").each(function(i) {
$(this).mouseenter(function(){
t=setTimeout("$('.div').eq("+i+").fadeIn()",500)
}).mouseleave(function(){
clearTimeout(t)
$(".div").eq(i).fadeOut();
})
});
不知道当时为啥会想得那么复杂 :
$(".list").mouseenter(function() {
if( $(this).data("time") ){
clearInterval( $(this).data("time") );
}
var _this = $(this);
$(this).data("time", setInterval(function(){
_this.children(".cover").animate({top: '0px'});
clearInterval( _this.data("time") );
_this.removeData("time");
},300));
}).mouseleave(function() {
if( $(this).data("time") ){
clearInterval( $(this).data("time") );
$(this).removeData("time");
}
$(this).children(".cover").animate({top: '145px'});
})
--------------------------------------------------------------------------setTimeout加参数20130805
var _sto = setTimeout;
window.setTimeout = function(callback,timeout,param)
{
var args = Array.prototype.slice.call(arguments,2);
var _cb = function()
{
callback.apply(null,args);
}
_sto(_cb,timeout);
}
--------------------------------------------------------------------------setTimeout加参数20130805
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>And the winner isn't...</title>
<style type="text/css">
a{width:100px; height:100px; background:#0FF; display: block; position:absolute}
.div{ width:100px; height:100px; background:#f36; display:none; position:absolute}
.warp{width:100px; height:100px; float:left; position:relative; margin:20px}
</style>
<script src="scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".warp").each(function(i) {
$(this).mouseenter(function(){
t=setTimeout("$('.div').eq("+i+").fadeIn()",500)
}).mouseleave(function(){
clearTimeout(t)
$(".div").eq(i).fadeOut();
}) });
})
</script>
</head>
<body>
<div class="warp" style=" ">
<a href="#"></a>
<div class="div"></div>
</div>
<div class="warp">
<a href="#"></a>
<div class="div" style=""></div>
</div>
<div class="warp">
<a href="#"></a>
<div class="div" style=""></div>
</div> </body>
</html>
mouseenter和mouseout中间的时间控制的更多相关文章
- Tuxedo 超时时间控制(转贴)
以下是转贴: TUXEDO超时控制全功略 摘要: 本<功略>集中了TUXEDO应用中,可能涉及到的所有时间参数,并分别对其进行详细描述,不但对其出处.取值等基本属性进行查证,而且,通过分析 ...
- 关于JS的时间控制实现动态效果及实例操作
关于JS的时间控制 <script> BOM //Bowers Object Model 浏览器对象模型 setTimeout()// 延迟执行一次 ...
- Quartz定时器中Cron时间控制表达式写法
Quartz定时器中Cron时间控制表达式写法: 1.表示形式 该表达式简洁简单,总共有7个空格分割的表达子式,形式为[* * * * * * *],而这七个位置上的东西表达方式有很多,意义从左往 ...
- Linux带有时间控制的多进程bash脚本
目标 以可控制的多进程执行,达到最大执行时长后停止脚本. 思路 1.产生fifo管道,并预填充n个值(与并发数相等) 2.记录脚本本身PID并启动计时器进程(计时终止后杀脚本本身PID) 3.并发执行 ...
- java如何优雅的实现时间控制
前言:最近小王同学又遇到了一个需求:线上的业务运行了一段时间,后来随着使用人数增多,出现了一个问题是这样的,一个订单会重复创建几次,导致数据库里出现了很多垃圾数据.在测试同学的不断测试下,发现问题出在 ...
- 最终解决 mouseenter, mouseleave , mouseout mousehover mousemove等事件的区别?
在jquery中, html页面的div的显示和隐藏, 修改等的功能, 最终都要由 事件 触发来引用, 不管是键盘事件, 还是鼠标事件... mouseenter和mouseleave是成对对应的, ...
- mouseover,mouseenter,mouseleave,mouseout
mouseover和mouseout对应 //鼠标移入移出触发该元素及子元素 mouseenter和mouseleave对应 //鼠标移入移出只触发该元素 看完例子即可知道其区别: mouseover ...
- WdatePicker()时间控制方式(转载+原创)
控制时间在制定范围内: <input class="wzsrk" name="startDateStr" id="startDateStr ...
- linux下socket connect 阻塞方式 阻塞时间控制
同事今天问我,如何在linux下的c代码里面控制connect的阻塞时间.应用的背景是:linux下的c程序有两个目标IP需要connect,如果用阻塞方式,当其中一个IP不能连接的情况下,程序将阻塞 ...
随机推荐
- .Net面試題
初级.NET开发人员 - 任何使用.NET的人都应知道的 1. 描述线程与进程的区别? 进程是系统所有资源分配时候的一个基本单位,拥有一个完整的虚拟空间地址,并不依赖线程而独立存在.进程可以定义程序的 ...
- CP,SCP 命令(包括windows与linux用xshell互传)
linux之cp/scp命令+scp命令详解 名称:cp 使用权限:所有使用者 使用方式: cp [options] source dest cp [options] source... direct ...
- 对Spring <context:annotation-config/>的理解
在基于主机方式配置Spring的配置文件中,你可能会见到<context:annotation-config/>这样一条配置,他的作用是向 Spring 容器注册 AutowiredAnn ...
- Oracle 分页实现
--分页实现------实行两行一页 --1 先查询按编号排序的所有用户信息 select t.* from T_USER t order by user_id ; --2 查询数据的前四行, ; - ...
- QWebView下载文件,QUrl中解析文件名
参考网址: http://blog.csdn.net/cdnight/article/details/23658715 http://www.tuicool.com/articles/AzeaUz h ...
- Native SQL
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- 选择屏幕(Selection Screen)
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- zoj 1199 几何公式推导
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=199 Point of Intersection Time Limit: ...
- Fiddler中session的请求/响应类型与图标对照表
- iOS - OC NSValue 值
前言 @interface NSValue : NSObject <NSCopying, NSSecureCoding> 将任意数据类型包装成 OC 对象 1.比较两个 NSValue 类 ...