javascript - 边框颜色更改仅在第一次起作用

标签 javascript jquery html css game-development

我正在尝试制作一个基于 javascript 的小游戏。

这是 Fiddle for the GAME

除了几个问题,它几乎可以正常工作:-

  1. On click of any TD, if the image is in that TD, cell border color should be green otherwise if you have clicked on wrong TD, border color turns to red.
    This functionality is working only first time you start the game. from next time it is always showing red border color.

  2. Till level 8, the changing of border color is visible, but as you increase the level, user cannot experience whether he has hit the correct cell or not. I want something like as soon as you have hit the correct cell, the color change should be visible and stable until image appears into another cell.

代码和建议的任何改进都是值得赞赏的。

最佳答案

第二次开始游戏时,调用startGame()

startGame() 中,您有一个 $('td').click(),它会第二次触发,所以每次点击时,它都会实际点击两次(一次 catch ,一次未命中)。

关于javascript - 边框颜色更改仅在第一次起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18270833/

相关文章:

javascript - 如何通过ID和值获取元素?

jquery - 单击按钮时动画 marginTop

javascript - webpack 构建中未加载字体

javascript - HTML Anchor Elm 对 VBA 的隐藏

javascript - 如何读取从 php 传递到 ajax jQuery 的多维关联数组?

javascript - 尝试使用 HTML5/CSS3/JS 创建带有 z-index 的堆叠菜单

PHP Bootstrap 3 文本关闭区域?

html - Bootstrap 3 : Tooltip image just after the input field?

javascript - 需要asp :TextBox when specific asp:CheckBoxList ListItem checked

javascript - 如何使用 JavaScript 检测移动设备?