本例是个非常简单的div拖动,有需要的朋友可根据自己的需求,添加相应的代码。欢迎拍砖 复制代码 代码如下: div width resize type="text/javascript"> <BR>function bindResize(el) <BR>{ <BR>//初始化参数 <BR>var els = document.getElementById('menu').style; <BR>//鼠标的 X 和 Y 轴坐标 <BR>x = 0; <BR>//邪恶的食指 <BR>$(el).mousedown(function (e) <BR>{ <BR>//按下元素后,计算当前鼠标与对象计算后的坐标 <BR>x = e.clientX - el.offsetWidth - $("#menu").width(); <BR>//在支持 setCapture 做些东东 <BR>el.setCapture ? ( <BR>//捕捉焦点 <BR>el.setCapture(), <BR>//设置事件 <BR>el.onmousemove = function (ev) <BR>{ <BR>mouseMove(ev || event); <BR>}, <BR>el.onmouseup = mouseUp <BR>) : ( <BR>//绑定事件 <BR>$(document).bind("mousemove", mouseMove).bind("mouseup", mouseUp) <BR>); <BR>//防止默认事件发生 <BR>e.preventDefault(); <BR>}); <BR>//移动事件 <BR>function mouseMove(e) <BR>{ <BR>//宇宙超级无敌运算中... <BR>els.width = e.clientX - x + 'px'; <BR>} <BR>//停止事件 <BR>function mouseUp() <BR>{ <BR>//在支持 releaseCapture 做些东东 <BR>el.releaseCapture ? ( <BR>//释放焦点 <BR>el.releaseCapture(), <BR>//移除事件 <BR>el.onmousemove = el.onmouseup = null <BR>) : ( <BR>//卸载事件 <BR>$(document).unbind("mousemove", mouseMove).unbind("mouseup", mouseUp) <BR>); <BR>} <BR>} <BR>var divResize=function(){ <BR>var totalHeight=$("html").height(); <BR>console.log(totalHeight); <BR>var topHeight=$("#top").height() <BR>$("#menu").height(totalHeight-topHeight); <BR>$("#rightbar").height(totalHeight-topHeight); <BR>} <BR>$(function() { <BR>divResize(); <BR>$(window).resize(divResize); <br><br>bindResize(document.getElementById('rightbar')); <BR>}); <BR> <BR>.content { <BR>width: 200px; <BR>background: #f1f1f1; <BR>text-align: center; <BR>border-color: #CCCCCC; <BR>border-style: solid; <BR>border-width: 0 1px; <BR>} <BR> style="width: 2px; background: #cccccc; cursor: e-resize;"> --%> 待拖拽的div style="width: 2px; background: #cccccc; cursor: e-resize; float: left;">