jquery鼠标停止移动事件
2013-12-21 00:00
323 查看
<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; }).mouseout(function(){ clearInterval(si); isRun = false; }); }); } })(jQuery); $(function(){ $("#div1,#div2").moveStopEvent(function(){ alert($(this).attr("id")); } ); }); </script> <div id="div1" style="width:200px;height:100px;background-color:#ccc;">div1</div> <br/> <div id="div2" style="width:200px;height:100px;background-color:#ccc;">div2</div>
相关文章推荐
- jquery鼠标停止移动事件
- jquery鼠标停止移动事件
- jQuery移动页面开发中的触摸事件与虚拟鼠标事件简介
- jQuery操作表格背景色迭代和鼠标移动事件(CSS中使用expression)
- jQuery事件 鼠标移动效果 onmouseover方法与onmouseout方法
- jQuery移动页面开发中的触摸事件与虚拟鼠标事件简介
- jquery模拟实现鼠标指针停止运动事件
- jQuery移动设备上支持滑动事件(jquery.touchSwipe.min.js)
- JQuery学习笔记之鼠标的各种事件
- jQuery事件-鼠标事件
- JS监听鼠标事件,鼠标移动到对象上,展示div
- 鼠标悬浮事件 -jQuery hover()方法
- jquery 实现超出部分隐藏,鼠标移动上显示全部文字
- 一个ADF Javascript 添加鼠标移动事件的例子
- Jquery创建层显示标题和内容且随鼠标移动而移动
- jQuery事件之鼠标事件
- jquery鼠标hover事件文字内容滑动遮罩效果
- jquery div 跟随鼠标移动
- C#如何监听全局的事件-例如鼠标移动事件
- screen,client,page三种确定鼠标坐标的区别和原生JS事件写法,区别于Jquery的$.on(x,y);和$.click()