jquery - Trouble adding double the divs i already have -
okay creating game fun. game involves 5 second timer , divs shapped boxes. first round start off 1 div purpose click on div before timer runs out. if pass go next level adds double boxes level 2 have 2 boxes level 3 4 boxes , on. having trouble creating double length of div. dont have code because nothing ive tried has worked. here jsfiddle:
<!doctype html> <html> <head> <title>jquery project: exploding game</title> <meta charset="utf-8"> <style> body, html { width: 960; height: 500%; } div.box { position: relative; width: 100px; height: 100px; background-color: orange; } div.exploding { position: absolute; width: 100px; height: 100px; background-color: red; } </style> </head> <body> </body> </html>
your javascript...
settimeout(function(){$("body").append("<div class='box'></div>").length() *2;}, 5000);
is saying...
after 5 seconds
<body/>
, append<div class='box'/>
it, number of divs appended (i.e. 1) , multiply number 2 discard result.
use this...
setinterval(function(){$(".box").clone().appendto("body");}, 5000);
it says...
every 5 seconds, elements of class box, make copy of them, , append copy body.
Comments
Post a Comment