A chameleon will usually change to any color depending on the color of the surface onto which it is in contact with since that is the color it will acquire.
A chameleon will change into many different colors. But their defense mechanism is to blend into the background it is near to hide itself from predators.