- Joined
- Mar 20, 2015
- Messages
- 1
- Reaction score
- 0
So in my program, divs are randomly created at different positions, but all with the same class. I am trying to get it so when ever one of the divs is created, they instantly begin to move to the left. I have this code
function ballleft() {
var ball = parseInt(document.getElementByClassName("ball").style.left);
document.getElementByClassName("ball").style.left = (ball - 10) + px;
}
function startBallMove() {
ball = document.getElementsByClassName("ball");
for (var i=0; i < ball.length; i++) {
ballleft(ball);
}
}
but it won't move the ball, is this because there is something wrong with the code or is it because startBallMove() is not actually being called. Thanks for the help.
function ballleft() {
var ball = parseInt(document.getElementByClassName("ball").style.left);
document.getElementByClassName("ball").style.left = (ball - 10) + px;
}
function startBallMove() {
ball = document.getElementsByClassName("ball");
for (var i=0; i < ball.length; i++) {
ballleft(ball);
}
}
but it won't move the ball, is this because there is something wrong with the code or is it because startBallMove() is not actually being called. Thanks for the help.