<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计算鼠标拖动的距离</title>
</head>
<body>
<script>
function mouse() {
var a;
var b;
var a1;
var b1;
document.οnmοusedοwn=function(ev) {
a = ev.screenX;
b = ev.screenY;
};
document.οnmοuseup=function (ev) {
a1 = ev.screenX;
b1 = ev.screenY;
console.log( Math.sqrt(Math.pow((a-a1),2)+(b-b1),2));
};
}
mouse();
</script>
</body>
</html>