基于jquery的获取mouse坐标插件的实现代码_Javascript教程-查字典教程网
基于jquery的获取mouse坐标插件的实现代码
基于jquery的获取mouse坐标插件的实现代码
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:/**Copyright(c)2010刘建华**Theabovecopyrightnoticeshallbe*includ...

复制代码 代码如下:

/*

* Copyright (c) 2010 刘建华

*

* The above copyright notice shall be

* included in all copies or substantial portions of the Software.

* Example:

<div>demo</div>

<div id="demo">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教程学习
    热门Javascript教程学习
    编程开发子分类