Initial condition (IF) does not work

0

I'm trying to play a game of old. So far I have been able to make the markings alternating with each shift and the function to delete the markings.

ps: I'm using black and red instead of ball and "x".

My problem is that the markup changes even after you've marked it if you click on it again. I want that once clicked the elements keep their markings (bgcolor) .

link

For this I tried to solve by putting the first if checking if the background has no initial color white, if it does not have false return and stop the function.

if(!casa.style.backgroundColor == "#FFF") return false;

Being that does not work.

    
asked by anonymous 10.11.2014 / 23:21

1 answer

5

The logical operator for different is: !=

And the return of property style.backgroundColor is in rgb (x, x, x) and not in hexacolor, so try with the following syntax:

if(casa.style.backgroundColor != "rgb(255, 255, 255)" && casa.style.backgroundColor != "") return false;

JSfiddle

    
11.11.2014 / 00:44