DJRobThaMan
07-31-2003, 11:53 AM
I'm trying to make a draggable div using javascript and I'm having a bit of a problem to clear document.onmousemove after I've already applied the function I'm using to follow the cursor with the div.
Anybody have any ideas as to how I could do this?
Here's what I'm using:
<html>
<head>
<script type="text/JavaScript">
<!--
var i;
var j;
function trackit(){
i = event.x;
j = event.y;
document.getElementById("tracker").style.left = i;
document.getElementById("tracker").style.top = j;
}
function drag(){
document.onmousemove = trackit;
}
function enddrag(){
???????????????????????
}
-->
</script>
</head>
<body>
<div id="tracker" style="position:absolute;background-color:red;width:50;height:50;" onMouseDown="drag()" onMouseUp="enddrag()">
</div>
</body>
</html>
Thanks
Anybody have any ideas as to how I could do this?
Here's what I'm using:
<html>
<head>
<script type="text/JavaScript">
<!--
var i;
var j;
function trackit(){
i = event.x;
j = event.y;
document.getElementById("tracker").style.left = i;
document.getElementById("tracker").style.top = j;
}
function drag(){
document.onmousemove = trackit;
}
function enddrag(){
???????????????????????
}
-->
</script>
</head>
<body>
<div id="tracker" style="position:absolute;background-color:red;width:50;height:50;" onMouseDown="drag()" onMouseUp="enddrag()">
</div>
</body>
</html>
Thanks