$(document).on('mousedown', '.hgc_dialogContent h2', function(e) {   var drag = $(this).parent(); //webkit内核和火狐禁止文字被选中   $('body').addClass('select'); if ($(e.target).hasClass('layer-close')) { //点关闭按钮不能拖拽模态框   return; } //鼠标点击物体那一刻相对于物体左侧边框的距离=点击时的位置相对于浏览器最左边的距离-物体左边框相对于浏览器最左边的距离   var diffX = e.clientX - drag.offset().left;   var diffY = e.clientY - (drag.offset().top - $(window).scrollTop());   $(document).on('mousemove', function(e) {     e = e || window.event; //兼容ie浏览器     var left = e.clientX - diffX;     var top = e.clientY - diffY; console.log(e.clientY)     if (left < 0) {       left = 0;     } else if (left > window.innerWidth - drag.width()) {       left = window.innerWidth - drag.width();     }     if (top < 0) {       top = 0;     } else if (top > window.innerHeight - drag.height()){       top = window.innerHeight - drag.height();     }     //移动时重新得到物体的距离,解决拖动时出现晃动的现象     drag.css({       'left': left + 'px',       'top': top + 'px'     })   })   $(document).on('mouseup', function(e) { //当鼠标弹起来的时候不再移动     $(document).unbind("mousemove");     $(document).unbind("mouseup");   }); return false });