为什么turnCount没有更新?(Why isn't turnCount updating?)
我正在尝试创建一个井字游戏。 你可以想象我只是在我的html中有一个包含三行和九个数据单元的表,所以我不打算发布它,但由于某种原因我在我的脚本(更新turnCount的那个)中的第一个函数没有'似乎在做任何事情。
var X = 'X'; var O = 'O'; var currentPlayer; var turnCount = 0; $(document).ready(function () { $('td').click(function () { turnCount += 1; }); }); var setCurrentPlayer = function () { if (turnCount % 2 === 0) { currentPlayer = O; } else { currentPlayer = X; } }; setCurrentPlayer(); $(document).ready(function () { $('td').click(function () { $(this).text(currentPlayer); }); });
I'm trying to create a tic-tac-toe game. As you can imagine I simply have a table with three rows and nine data-cells in my html so I won't bother posting that, but for some reason the first function I have in my script(the one that updates turnCount) doesn't seem to be doing anything.
var X = 'X'; var O = 'O'; var currentPlayer; var turnCount = 0; $(document).ready(function () { $('td').click(function () { turnCount += 1; }); }); var setCurrentPlayer = function () { if (turnCount % 2 === 0) { currentPlayer = O; } else { currentPlayer = X; } }; setCurrentPlayer(); $(document).ready(function () { $('td').click(function () { $(this).text(currentPlayer); }); });
原文:https://stackoverflow.com/questions/16997089
满意答案
新的Bitwise操作函数在v2.2.6中引入。
如果你无法使用2.3,那么获得2.2.9。 它对我有用。
New Bitwise operating functions were introduced in v2.2.6.
If you are not able to cop up with 2.3 then get 2.2.9. It worked for me.
相关问答
更多HSQLDB忽略大小写(HSQLDB ignore case)
通过按位运算确定返回类型(Determining return type via bitwise operation)
找不到HSQLDB HAVING对象(HSQLDB HAVING object not found)
HSQLDB - 未找到按位操作方法BITANDNOT()(HSQLDB - bitwise operation method BITANDNOT() is not found)
HSQLDB停止定期执行CHEKPOINT操作,日志文件也在不断增长(HSQLDB is stop doing periodic CHEKPOINT operation and log files is keep growing)
我的HSQLDB上的更改不一致(Changes on my HSQLDB are inconsistent)
如何更改HSQLDB服务器侦听的端口(How to change port that HSQLDB server listens on)
为什么ArrayDeque类在pollFirst方法中使用按位运算?(Why the ArrayDeque class use bitwise operation in the pollFirst method?)
表没有找到Hibernate和HSQLDB(Table Not Found with Hibernate and HSQLDB)
不导出Hibernate + HSQLDB架构(Hibernate + HSQLDB schema is not exported)
相关文章
更多fw:Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】
顶 Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】
gui求jtapi高手T_T
webservice可不可以实现动态的返回类型:<T> List<T> getList(T a)
收集的英语资源(不断更新)
Don’t work. Be hated. Love someone.
Git 常用命令 - 不断更新中
Hadoop出现元数据不能更新且SNN合并失效
关于如何参与到开源项目中《How To Succeed In Open Source ( In Ways You Haven't Considered Yet )》
javax.imageio.IIOException: Can't create output stream!的解决方案
最新问答
更多如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
maven中snapshot快照库和release发布库的区别和作用
arraylist中的搜索元素(Search element in arraylist)
从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
从iframe访问父页面的id元素(accessing id element of parent page from iframe)
linux的常用命令干什么用的
Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!