לא הבנתי למה left נמצא במשתנה בצורה הזו. קשה לדעת בלי לראות את מה שמחוץ לפונקציה.
אולי התכוונת למשהו כזה:
אולי התכוונת למשהו כזה:
קוד:
function random(_left) {
var div = document.createElement("div");
div.style.display = "inline-block";
div.style.left = _left + "px";
div.style.width = "100px"
div.style.height = "100px"
div.style.top = "0px";
div.style.position = "absolute";
div.style.animationName = "anim1";
div.style.animationDuration = "2s";
div.style.backgroundColor = "red";
div.style.zIndex = "5";
document.getElementById("board").appendChild(div);
}
var myRandom = Math.floor((Math.random() * 200) + 1);
random(myRandom);
קוד: