A drag function that does not use onmouseup. ff, The onmousemove mouse is pressed by 1, so it cannot be used like this.
<Script language = "JavaScript"> <! -- Function drag (obj) {var s = obj. style var B = document. body var x = event. clientX + B. scrollLeft-s. pixelLeft var y = event. clientY + B. scrollTop-s. pixelTop var m = function () {if (event. button = 1) {s. pixelLeft = event. clientX + B. scrollLeft-x s. pixelTop = event. clientY + B. scrollTop-y} else document. detachEvent ("onmousemove", m)} document. attachEvent ("onmousemove", m) if (! This. z) this. z = 999 s. zIndex = ++ this. z event. cancelBubble = true} // --> SCRIPT <body ondragstart = "return false" style = "margin: 0px"> <p onmousedown = "drag (this) "style =" left: 250px; position: absolute; width: 300px; height: 300px; background: #000 "> <p onmousedown =" drag (this) "style =" top: 100px; position: absolute; width: 100px; height: 100px; background: # F0F "> </p> <p onmousedown =" drag (this) "style =" top: 150px; position: absolute; width: 100px; height: 100px; background: # F00 "> </p> <p onmousedown =" drag (this) "style =" left: 100px; position: absolute; width: 100px; height: 100px; background: #0F0 "> </p> <p onmousedown =" drag (this) "style =" left: 150px; position: absolute; width: 100px; height: 100px; background: # 00F "> </p> </body>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]