generate random opacity number using math random
Posted
by
TechyDude
on Stack Overflow
See other posts from Stack Overflow
or by TechyDude
Published on 2012-09-22T21:31:52Z
Indexed on
2012/09/22
21:37 UTC
Read the original article
Hit count: 348
I am trying to generate a random number for the css opacity.
This is what I tried so far.
CSS
.test{
position : absolute;
width : 15px;
height : 15px;
border-radius:15px;
background-color : black;
}?
Script
$(function() {
for (var i = 0; i < 300; i++) {
$("<div>", {
class: "test",
css: {
opacity: randomOpacity
}
}).appendTo("body");
}
function randomOpacity() {
var opac = 0;
opac = Math.random() < 1;
console.log(opac);
}
randomize();
});?
The Fiddle
© Stack Overflow or respective owner