基于jquery的獲取mouse坐標(biāo)插件的實(shí)現(xiàn)代碼
更新時(shí)間:2010年04月01日 23:24:54 作者:
用jquery實(shí)現(xiàn)的獲取mouse坐標(biāo)的實(shí)現(xiàn)代碼,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:
/*
* 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>
<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 && /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);
相關(guān)文章
50 個(gè) jQuery 插件可將你的網(wǎng)站帶到另外一個(gè)高度
Query架構(gòu)的開(kāi)發(fā)人員能夠創(chuàng)建一個(gè)插件代碼來(lái)擴(kuò)展其功能,從而能夠產(chǎn)生一些最好的插件,讓你的網(wǎng)站或任何給定的項(xiàng)目達(dá)到一個(gè)全新的水平。2016-04-04分享33個(gè)jQuery與CSS3實(shí)現(xiàn)的絢麗鼠標(biāo)懸停效果
今天整理了33個(gè)使用jQuery與CSS3實(shí)現(xiàn)絢麗的鼠標(biāo)懸停效果,有些是純CSS3的,這些效果你完全可以用在你的網(wǎng)頁(yè)上,讓網(wǎng)站獲得更好的體驗(yàn)2014-12-12jquery取子節(jié)點(diǎn)及當(dāng)前節(jié)點(diǎn)屬性值的方法
這篇文章主要介紹了jquery取子節(jié)點(diǎn)及當(dāng)前節(jié)點(diǎn)屬性值的方法,比較實(shí)用,需要的朋友可以參考下2014-09-09JQuery實(shí)現(xiàn)的按鈕倒計(jì)時(shí)效果
這篇文章主要介紹了JQuery實(shí)現(xiàn)的按鈕倒計(jì)時(shí)效果,涉及jQuery結(jié)合時(shí)間函數(shù)動(dòng)態(tài)修改按鈕屬性的相關(guān)技巧,需要的朋友可以參考下2015-12-12jQuery學(xué)習(xí)筆記 操作jQuery對(duì)象 屬性處理
HTML文檔,不但有一系列語(yǔ)義標(biāo)簽,每個(gè)標(biāo)簽下屬還有一系列屬性節(jié)點(diǎn)。自然我們也想去操作這些屬性節(jié)點(diǎn)。格式仍然為$(selector).方法2012-09-09jQuery zTree搜索-關(guān)鍵字查詢 遞歸無(wú)限層功能實(shí)現(xiàn)代碼
這篇文章主要介紹了zTree搜索功能 -- 關(guān)鍵字查詢 -- 遞歸無(wú)限層的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2018-01-01