random position of divs in javascript
I'm trying to make Divs to appear randomly anywhere on a webpage with javascript. So a div appears then disappears, then another div appears somewhere else on the page then disappears, then another div appears again in another random spot on the page then disappears, and so on. I'm not sure on how to generate random units in pixels or what technique to use to generate random positions. How do I do that? Here's my code: var currentDivPosition = myDiv.offset(), myDivWidth = myDiv.width(), myDivHeight = myDiv.height(), var myDiv = $('<div>'), finalDivPositionTop, finalDivPositionLeft; myDiv.attr(