代码如下:
<script src="jquery.js"></script>
<script>
(function($){
$.fn.movestopevent = function(callback){
return this.each(function() {
var x = 0,
y = 0,
x1 = 0,
y1 = 0,
isrun = false,
si,
self = this;
var sif = function(){
si = setinterval(function(){
if(x == x1 && y ==y1){
clearinterval(si);
isrun = false;
callback && callback.call(self);
}
x = x1;
y = y1;
}, 500);
}
$(this).mousemove(function(e){
x1 = e.pagex;
y1 = e.pagey;
!isrun && sif(), isrun = true;
}).mouut(function(){
clearinterval(si);
isrun = false;
});
});
}
})(jquery);
$(function(){
$("#p1,#p2").movestopevent(function(){
alert($(this).attr("id"));
}
);
});
</script>
<p id="p1" style="width:200px;height:100px;background-color:#ccc;">p1</p>
<br/>
<p id="p2" style="width:200px;height:100px;background-color:#ccc;">p2</p>
如对本文有疑问, 点击进行留言回复!!
同事牛逼啊,写了个隐藏 bug,我排查了 3 天才解决问题!
【JavaScript笔记(一)】万丈高楼平地起 - 基本概念篇
轻松解决 org.apache.taglibs.standard.tlv.JstlCoreTLV 困惑
网友评论