//点击弹出提交应用 function drag(obj){ var odiv=$(obj); var drag_zoom=odiv.find(‘.pop-top‘); //拖动 drag_zoom.mousedown(function(e){ var odiv_L=$(this).offset().left; odiv_T=$(this).offset().top; onow_L=e.pageX-odiv_L; onow_T=e.pageY-odiv_T; $(document).mousemove(function(e){ var X=e.pageX-onow_L; Y=e.pageY-onow_T; if(X<=0){ X=0; }else if(X>=$(window).width()-odiv.outerWidth(true)){ X=$(window).width()-odiv.outerWidth(true) }; if(Y<=0){ Y=0; }else if(Y>=$(window).height()-odiv.outerHeight(true)){ Y=$(window).height()-odiv.outerHeight(true) }; odiv.css({‘left‘:X+‘px‘,‘top‘:Y+‘px‘}); if(window.getSelection){//解决拖动时选中文字 window.getSelection().removeAllRanges(); //w3c }else if(document.selection){ document.selection.empty();//IE }; }); $(document).mouseup(function(){ $(this).unbind(‘mousemove‘); }); }); }; drag(‘.pop-div‘);
时间: 2024-11-05 16:08:01