I'm not an expert in developing games, but I believe a solid approach is to keep the game state in a data structure and let the screen display represent the current status. When the status changes, the display is updated accordingly.
Maybe have a look at the Backgammon sample app (http://www.tersus.com/#Id=3912). A simpler example is the Memory Game (http://www.tersus.com/#Id=2248).
For best results, use the Firefox browser..