不要使用“modal”,“Modal”会在内容后面创建一个“div”并阻止用户使用其他屏幕控件,如果您想测试:jsfiddle
var oldX = 0;
var oldY = 0;
var mouseDown = false;
$('.modal_').mousedown(function(e){
log('mousedown');
oldX = e.clientX;
oldY = e.clientY;
console.log(oldX);
mouseDown = true;
}).mouseup(function(e){
log('mosueup');
mouseDown = false;
}).mousemove(function(e){
if(mouseDown ){
self = $(this);
var top = parseInt(self.css('top').replace('px', ''));
var left = parseInt(self.css('left').replace('px', ''));
log(left + (oldX - e.clientX) + ' , ' + top);
self.css('left', (left + e.clientX-oldX) + 'px');
self.css('top', (top + e.clientY-oldY) + 'px');
oldX = e.clientX;
oldY = e.clientY;
}
});
$('.modal_').on('dragstart', function(event) { event.preventDefault(); });