event.x,event.clientX,event.offsetX区别
x:設(shè)置或者是得到鼠標(biāo)相對(duì)于目標(biāo)事件的父元素的外邊界在x坐標(biāo)上的位置。?
clientX:相對(duì)于客戶區(qū)域的x坐標(biāo)位置,不包括滾動(dòng)條,就是正文區(qū)域。?
offsetx:設(shè)置或者是得到鼠標(biāo)相對(duì)于目標(biāo)事件的父元素的內(nèi)邊界在x坐標(biāo)上的位置。?
screenX:相對(duì)于用戶屏幕。
演示代碼:
<table border=1 cellpadding=15 cellspacing=15 style="position:relative;left:100;top:100">
<tr><td>
<div οnclick="show()" style="background:silver;cursor:hand">
Click here to show.
</div>
</td></tr>
</table>
<script>
function show(){
alert("window.event.x:"+window.event.x+"\nwindow.event.y:"+window.event.y+"\nevent.clientX:"+event.clientX+"\nevent.clientY:"+event.clientY+"\nevent.offsetX:"+event.offsetX+"\nevent.offsetY:"+event.offsetY+"\nwindow.event.screenX:"+window.event.screenX+"\nwindow.event.screenY:"+window.event.screenY);
}
</script>
轉(zhuǎn)載于:https://www.cnblogs.com/hr2014/p/3779320.html
總結(jié)
以上是生活随笔為你收集整理的event.x,event.clientX,event.offsetX区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用心疗眼
- 下一篇: LeetCode:Sudoku Solv