I have multiple draggable frames within my HTML, each with unique "left" and "top" values in the CSS. I am looking to randomize these values every time the page is refreshed or loaded, with a range of 10 to 1000 pixels.
Here is an example of the CSS for one of the divs:
#mydiv1 {
position: absolute;
z-index: 0;
width: 250px;
height: 250px;
top: 400px;
left: 500px;
background-color: black;
border: 2px solid #e8ff26;
text-align: center;
box-shadow: 2px 2px 4px #888888;
cursor: move;
}
The goal is to randomize the "left" and "top" values for all divs on the page, not just one.
I have tried some JavaScript examples without success. Here is an example of one attempt that didn't work:
$(function(){
var divClass = "div_" + Math.floor((Math.random() * 10) + 1);
$('body').addClass(divClass);
});
Another unsuccessful attempt:
$(document).ready(function() {
$("body").css("left", "(" + Math.floor(Math.random() * (10)) );
});