(1) var div = document.getElementById('box');
var X, Y;
function Move(e) {
console.log(e);
X = e.clientX - 50
Y = e.clientY - 50
div.style.top = Y + 'px'
div.style.left = X + 'px'
}
div.addEventListener('mousedown', function () {
document.addEventListener("mousemove", Move)
})
document.addEventListener("mouseup", function () {
document.removeEventListener("mousemove", Move)
X = 0;
Y = 0;
})
(2)
var div = document.querySelector('div');
var flag = false;
var x = 0, y