联系我们
简单又实用的WordPress网站制作教学
当前位置:网站首页 > 网页前端技术 > 正文

基于jquery的获取mouse坐标插件的实现代码 - Web前端

作者:98wpeu发布时间:2026-10-09分类:网页前端技术浏览:23


导读:复制代码代码如下:/**Copyright(c)2010刘建华**Theabovecopyrightnoticeshallbe*includedi...

复制代码 代码如下:
/*
* 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>
<scripttype="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);

标签:坐标插件代码Webmousejquery


网页前端技术排行
最近发表
网站分类
标签列表