I have created a small game, in which some blocks are move around a main div. The mouse which also holding a div (I had assigned the position of cursor to that div).
I just want to trace out, whether the cursor div is moving over the blocks(those are also div). If it comes like that then the game will be over.
How can I detect whether the block or cursor div moves over each other?
If you’re using jQuery, you can find the left, top, width and height of a div by using these:
Use those to work out the left, right, top and bottom of each div. Then two divs overlap each other if: