score:1

Accepted answer

You need to set the boxColour variable inside the click handler, otherwise it's only set once and not updated when the colour changes. Changed jsfiddle here.


Related Query