hola,
ps aver
si esto te
funciona ....
Código HTML:
<html>
<head>
<style>
#capa1
{
width: 35px;
height: 35px;
background-color: #000000;
position:absolute;
}
#capa2
{
width: 30px;
height: 30px;
background-color: red;
position:absolute;
}
</style>
<script>
function Mover(obj){
this .obj = document.getElementById(obj);
this .activado = false;
this .activar = function(){
this .activado = !this .activado;
};
this .mover = function( e){
if(this .activado == true){
this .obj.style.marginTop = (e.clientY-15)+"px";
this .obj.style.marginLeft = (e.clientX-15)+"px";
}
};
}
var capa1,capa2;
onload = function(){
capa1 = new Mover("capa1");
capa2 = new Mover("capa2");
};
</script>
</head>
<body onmousemove="capa1.mover( event); capa2.mover( event);">
<div id="capa1" onmousedown="capa1.activar();" onmouseup="capa1.activar();"></div>
<div id="capa2" onmousedown="capa2.activar();" onmouseup="capa2.activar();"></div>
</body>
</html>
bueno saludos
:]