I have the following code
function randomizer(start, end)
{
return Math.floor((end - start) * Math.random()) + 1;
}
var top_pos = randomizer(1, $(document).height());
$('.element_selector').css('top', top_pos + 'px');
but the result is not what I realy expect from. The most of the times the element is places near to top (about 80% of the times).
Is there any better solution to place my random element in realy random position into vertical axes ?
Math.random()will return a value like0.318etc.you could do
Math.random() * 10(or*20) to increase the value.