js, which needs to pass in first,modify. Because I want to reuse the move function, but there are places where you don"t need modify, and places where you don"t need it, even if you pass a null value, you can"t run it.
is there any way to run without passing a fixed number of parameters?
function moveTest() {
var first = document.getElementById(id);
var modify = {
y: function () {
statements
}
};
move(first, modify); //
}
function move(first, modify) {
first.onmousedown = function (e) { //onclickonmouseover,onmousedown
modify.y(); //
var x = e.clientX - first.offsetLeft;
var y = e.clientY - first.offsetTop;
document.onmousemove = function (e) {
var left = e.clientX - x;
var top = e.clientY - y;
first.style.left = left + "px";
first.style.top = top + "px";
document.onmouseup = function () { //;
document.onmousemove = null;
document.onmouseup = null;
}
}
},