javascript - Adding random number of images inside div -
I have What I'm trying to do here but it is not working please You probably should use a clone. Why As Simone suggests, or you can create new images: & lt; Div & gt; and I want to add images to it. The number of images will be randomly different
$ (document) .ready (function () {var img = document.getElementById ("img"); $ (($ I; l> = randomnumber; i ++) {$ (this) Click to (function () { Var randomnumber = Math.floor (Math.random (* * 11) + 1; .append (img);}}};});
function getImage () {var img = new Image (); Img.src = "http: //cdn.acidcow Com / pics / 20110830 / lolcats_ever_13.jpg "img.width = 200; return IMG;} var rand = Math.flur (math.rendum) * 11) + 1, IMG CONTAINER = $ (" #IMG CONTAINER "), I; $ ("#ImGNo") for text (rand). (I = 0; i & lt; rand; i ++) {imgContainer.append (getImage ()); }
Comments
Post a Comment