事件调用<img src="abc.jpg" οnclick="Mousedown(this)"/>
var move = false;
function Mousedown(obj) {
if (event.button == 1 &&
//如果要拖动其他元素,则要吧"IMG"改为其他元素名称,如"div"
event.srcElement.tagName.toUpperCase() == "IMG" &&
move != false) {
obj.setCapture();
move = true;
}
}
function Mouseup(obj) {
obj.releaseCapture();
move = false;
}
function Mousemove(obj) {
if (move == true) {
obj.style.left = event.clientX - 50;
obj.style.top = event.clientY - 10;
}
}