Here i am drag an element and droping in another place it works well if i don't use event listeners but if i use it in this format it is not performing "place" operation.
this link contains my code "with Event Listeners" Visit http://jsfiddle.net/vishwateja2000/wHprQ/2/
this link contains my code "without Event Listeners" Visit http://jsfiddle.net/vishwateja2000/W2Pgq/1/
document.getElementById("div2").addEventListener("mousedown", down);
function down(){
t=1;
document.getElementById("div1").addEventListener("mouseup", place);
document.getElementById("div1").addEventListener("mousemove",function() {
myFunction(event);
});
}
function place(){
document.getElementById("div1").removeEventListener("mousemove",function() {
myFunction(event);
});
}
function placeobj(x,y,x1,y1,l,r){
var cpx = parseInt(x);
var cpy = parseInt(y);
var amtx=parseInt(x1);
var amty=parseInt(y1);
var of=10;
document.getElementById("div2").style.left=cpx-amtx+l+"px";
document.getElementById("div2").style.top=cpy-amty+r+"px";
}
function myFunction(e) {
if(t==1){
x1 = e.clientX;
y1 = e.clientY;
var el=document.getElementById('div2');
l=el.offsetLeft;
r=el.offsetTop;
t=10;
}
x = e.clientX;
y = e.clientY;
placeobj(x,y,x1,y1,l,r);
}