Three events involving the mouse:
OnMouseDown, OnMouseMove, onmouseup
<script type = "Text/javascript" >
var BODY = document.getelementsbytagname (' body ') [0];
Create a div and set its style
var box = document.createelement (' div ');
Box.style.width = ' 100px ';
Box.style.height = ' 100px ';
Box.style.background = ' Blue ';
box.style.position = ' absolute ';
Box.onmousedown = function (event) {
Event = Event | | window.event;
Get the location of the mouse click away from the left side of the Div
var Positionx = Event.clientx-box.offsetleft;
var positiony = event.clienty-box.offsettop;
Document.onmousemove = function (event) {
Event = Event | | window.event;??
var DivX = Event.clientx-positionx;
var divy = Event.clienty-positiony;
Box.style.left = DivX + ' px ';
Box.style.top = divy + ' px ';
}
Document.onmouseup = function () {
Document.onmousemove = null;
}?
}
Body.appendchild (box);
</script>
JavaScript--(click Div, move with mouse)