Home >Web Front-end >JS Tutorial >Implementation code of getting mouse coordinates plug-in based on jquery_jquery

Implementation code of getting mouse coordinates plug-in based on jquery_jquery

WBOY
WBOYOriginal
2016-05-16 18:30:35953browse

复制代码 代码如下:

/*
* 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 && /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);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn