how can i know that a specific is on another specific after dragging the first and drop it I am using this code in the head of my document to enable drag and drop of my divs
var dragapproved=false var z,x,y function move(){ if (event.button==1&开发者_如何学JAVA;&dragapproved){ z.style.pixelLeft=temp1+event.clientX-x z.style.pixelTop=temp2+event.clientY-y return false } } function drags() { if (!document.all) return if (event.srcElement.className=="drag") { dragapproved=true z=event.srcElement temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.onmousemove=move } } document.onmousedown=drags document.onmouseup=new Function('dragapproved=false')
You might consider using a javascript library such as JQuery to help you with this sort of thing--a lot of these sorts of functions are built-in.
hopes,
Kevin is right do not try to implement a dragable feature on your own. Jquery and Jquery UI have already done this.
Learn JQuery! You'll never regret it.
Look here for a demo of draggable object using JQuery library : link text
Good luck!
精彩评论