/** ********设置div随意拖动 start ******* */
var dragging = false;
var iX, iY;
$("#divID").mousedown(function(e) {
dragging = true;
iX = e.clientX - this.offsetLeft;
iY = e.clientY - this.offsetTop;
this.setCapture && this.setCapture();
return false;
});
document.onmousemove = function(e) {
if (dragging) {
var e = e || window.event;
var oX = e.clientX - iX;
var oY = e.clientY - iY;
$("#divID").css({
"left": oX + "px",
"top": oY + "px"
});
return false;
}
};
$(document).mouseup(function(e) {
dragging = false;
// $("#divID")[0].releaseCapture();
e.cancelBubble = true;
})
/** ********设置div随意拖动 start ******* */
设置div随意拖动
最新推荐文章于 2024-07-17 09:19:35 发布