jq获取鼠标位置

时间:2022-10-19 10:24:16

jq获取鼠标位置

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
$().ready(
function () {
$(
"#cans").bind('mousemove', function (event) {
var x=event.clientX;
var y=event.clientY;
$(
"#res").text("坐标:x轴"+x+"坐标:y轴"+y);
});
});
</script>
</head>
<body>
<canvas id="cans" width="200" height="200">浏览器不支持canvas</canvas>
<div id="res"></div>
</body>
</html>