作家
登录

基于jquery的获取mouse坐标插件的实现代码

作者: 来源:www.28hudong.com 2013-03-30 01:42:45 阅读 我要评论

复制代码 代码如下:/* * 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 && /MSIEs(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);

  推荐阅读

  javascript 程序库的比较(一)之DOM功能

1,Prototype程序库    这是第一个把document.getElementById()简化为$的程序库。    比如:原来的var myele=document.getElementById('id')等价于var myele=$('id') 此外,$还扩展了一些功能    比如:var >>>详细阅读


本文标题:基于jquery的获取mouse坐标插件的实现代码

地址:http://www.17bianji.com/kaifa2/JS/26696.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)