基于jquery的获取mouse坐标插件的实现代码
2010-04-01 00:00
381 查看
/* * Copyright (c) 2010 刘建华 * * The above copyright notice shall be * included in all copies or substantial portions of the Software. * Example: <div style="height:1000px">demo</div> <div id="demo" style="height:50px; background:purple; width:50px;z-index:999999; position:absolute;left:-1000px;top:-1000px;">demo</div> <script type="text/javascript" > var o = $(document); o.mousemove( function(e){ var d = document.getElementById("demo"); d.style.left = ($.mouse(e).left + 5) + "px"; d.style.top = ($.mouse(e).top + 5) + "px"; }); </script> */ /* * mouse Plugin for jQuery * Version: 1.0 * Release: 2010-03-30 */ (function($) { //Main Method jQuery.mouse = function(e){ var mouseleft = 0; var mousetop = 0; if(!($.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent))) { mouseleft=e.pageX; mousetop=e.pageY; } else { var _top = document.compatMode=="CSS1Compat" ? document.documentElement.scrollTop : document.body.scrollTop; var _left = document.compatMode=="CSS1Compat" ? document.documentElement.scrollLeft : document.body.scrollLeft; mouseleft=_left+event.clientX; mousetop=_top+event.clientY; } return {left:mouseleft,top:mousetop} ; }; })(jQuery);
相关文章推荐
- 基于jquery的获取mouse坐标插件的实现代码
- 基于JQuery的Swiper插件实现移动手机端幻灯片切换(可在每一张幻灯片div中插入自定义的元素,代码简介,扩展性好。)
- Js和JQuery获取鼠标指针坐标的实现代码分享
- jQuery实现图片轮播效果代码(基于jquery.pack.js插件)
- jquery获取mouse坐标插件
- Js和JQuery获取鼠标指针坐标的实现代码分享
- 基于jquery实现轮播焦点图插件
- 基于jQuery的输入框无值自动显示指定数据的实现代码
- jquery解析XML及获取XML节点名称的实现代码
- 基于jquery的Repeater实现代码
- 基于jQuery实现仿51job城市选择功能实例代码
- 基于jQuery.i18n.properties插件实现前端页面国际化
- Jquery 弹出层插件实现代码
- 基于jQuery实现的Ajax 验证用户名是否存在的实现代码
- 基于jquery实现的树形菜单效果代码
- ****timeago.js插件:jquery实现几分钟前、几小时前、几天前等时间差显示效果的代码实例
- jQuery代码实现实时获取时间
- 分享几个基于jQuery不错的前端相册展示插件代码