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

爱眼色

爱眼色

2016-02-19 13:33

图老师设计创意栏目是一个分享最好最实用的教程的社区,我们拥有最用心的各种教程,今天就给大家分享基于jquery的获取mouse坐标插件的实现代码的教程,热爱PS的朋友们快点看过来吧!

代码如下:

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)
/*
* Copyright (c) 2010 刘建华
*
* The above copyright notice shall be
* included in all copies or substantial portions of the Software.
* Example:
divdemo/div
divdemo/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);

展开更多 50%)
分享

猜你喜欢

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

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

jQuery插件 tabBox实现代码

Web开发
jQuery插件 tabBox实现代码

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Jquery 弹出层插件实现代码

Web开发
Jquery 弹出层插件实现代码

基于jquery用于查询操作的实现代码

Web开发
基于jquery用于查询操作的实现代码

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

jquery 获取json数据实现代码

Web开发
jquery 获取json数据实现代码

基于jquery的让页面控件不可用的实现代码

Web开发
基于jquery的让页面控件不可用的实现代码

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

VisualBasic变量、常数和数据类型及过程概述六

VisualBasic变量、常数和数据类型及过程概述六

jQuery 第二课 操作包装集元素代码

jQuery 第二课 操作包装集元素代码
下拉加载更多内容 ↓