samedi 28 février 2015

Javascript if statement if (ball.style.left === '0px') {

I think the problem is really simple, but I'm not seeing it. I just want to move the "ball" to the left 132.5px when I click the "dice" and if the ball is 0px left.


I think the if statement is wrong!! Can someone help me?



var ball = document.getElementById('ball');
var dice = document.getElementById('dice');

function move() {
if (ball.style.left === '0px') {
ball.style.left = 132.5 + 'px';
}

}

dice.onclick = move;

Aucun commentaire:

Enregistrer un commentaire