3 Star 18 Fork 7

杨得朝/web-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
JS之clientX,clientY,screenX,screenY,offsetX,offsetY区别测试.html 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
杨得朝 提交于 2020-07-16 19:37 . submit
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
<style>* {
padding: 0;
margin: 0;
}
.container {
width: 200px;
height: 100px;
border: 1px solid #c00;
}
input[type="button"] {
margin: 50px;
border: none;
width: 100px;
height: 50px;
background: green;
}
</style>
</style>
</head>
<body>
<span style="white-space:pre"> </span>
<div id="div" class="container"></div>
<span style="white-space:pre"> </span>
<div id="div1" class="container"></div>
<span style="white-space:pre"> </span><input type="button" value="test" onclick="test()"/>
</body>
</html>
<script>
document.onmousemove = function(ev) {
var e = ev || window.event;
var div = document.getElementById('div');
div.innerHTML = "clientX: " + e.clientX + ",clientY:" + e.clientY +
"</br> screenX:" + e.screenX + ",screenY:" + e.screenY;
}
function test(ev) {debugger;
var e = ev || window.event;
var div1 = document.getElementById('div1');
div1.innerHTML = "offsetX:" + e.offsetX + ",offsetY : " + e.offsetY;
}
</script>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/yangdechao_admin/web-test.git
git@gitee.com:yangdechao_admin/web-test.git
yangdechao_admin
web-test
web-test
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385