el.onmousedown = function(ev){
el.style.position="absolute"
var ev = ev||event;
var disX = ev.clientX - this.offsetLeft;
var disY = ev.clientY - this.offsetTop;
document.onmousemove = function(ev){
var ev = ev||event;
el.style.left = ev.clientX - disX + 'px';
el.style.top = ev.clientY - disY + 'px';
}
document.onmouseup = function(){
document.onmousemove = null;
}
};
draggable,移动元素
最新推荐文章于 2023-03-15 10:00:46 发布