Need help with moving a div

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top