欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

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

程序员文章站 2022-05-21 10:45:16
...
复制代码 代码如下:

/*
* Copyright (c) 2010 刘建华
*
* The above copyright notice shall be
* included in all copies or substantial portions of the Software.
* Example:
demo

demo


*/

/*
* 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坐标