# Buttons Which Change Color, Each Time Pressed [closed]

I need to have 100 buttons, which their color is defined by the parity of number of times they are pressed: If they're pressed an even number of times their color is blue, and otherwise red. I don't know how to use 'Button' and 'Dynamic' to do so.

-

## closed as off-topic by belisarius, Michael E2, Kuba, Pickett, ArtesNov 7 '13 at 22:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – belisarius, Michael E2, Kuba, Pickett, Artes
If this question can be reworded to fit the rules in the help center, please edit the question.

Example right from the help DynamicModule[{x = 0}, Button["xxx", x = Mod[x + 1/10, 1], Background -> Dynamic[Hue[x]]]] Voting to close –  belisarius Nov 7 '13 at 22:03
To add to what belisarius said, you just need to change the x = Mod[...] line to return Blue if x is Red and vice versa. That automatically takes care of the even/odd. Also, remove the Hue[]. –  rm -rf Nov 7 '13 at 22:07
@belisarius As a matter of fact, I had found another example from the help before my post, but I couldn't change it so that the red/blue colors work. –  Behzad Nov 7 '13 at 22:11
I don't remember where but there is nice way shown in documentation with ReplaceAll: DynamicModule[{bg = Red}, Button["xxx", bg = bg /. {Red -> Blue, Blue -> Red}, Background -> Dynamic[bg]]] –  Kuba Nov 7 '13 at 22:13
@Behzad The colors problem is easy (you got three comments about that instantly) the hard part is doing that for 100 buttons. But you're not still facing it –  belisarius Nov 7 '13 at 22:20

Table[DynamicModule[{x = 0},