为什么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
2024-03-27 16:03

满意答案

新的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)

删除“(引号) 默认情况下,如果没有引号,则名称不区分大小写。 但是您将表名放在引号之间,因此它们完全按照区分大小写进行注册。 然后两个表名称不同,HSQLDB将不匹配。 这将有效: import java.sql.*; public class Main { public static void main(String[] args) throws Exception { Connection c = DriverManager.getConnection("jdbc:hsqldb...

通过按位运算确定返回类型(Determining return type via bitwise operation)

Java 8增加了将lambda转换为匿名交集的能力。 返回类型既是Comparator<T>又是Serializable 参考: assylias的答案在这里 文档 注意: Java有时会为运算符添加新的语法含义,以保持向后兼容性。 Java 8 adds the ability to cast the lambda into an anonymous intersection. The return type is both a Comparator<T> and Serializable R...

找不到HSQLDB HAVING对象(HSQLDB HAVING object not found)

您的示例可以像HSQLDB一样编写。 仅当Orders表包含单个行时,它才返回结果。 但是如果1实际上是SELECT列表中的另一个表达式,则需要将其写出: SELECT A.id, 1 as myAlias FROM Orders A WHERE A.someKz = 2 AND (SELECT count(*) FROM Orders) = 1 SELECT A.id, A.acol * 12 as myAlias FROM Orders A WHERE A.someKz = 2 AND (S...

HSQLDB - 未找到按位操作方法BITANDNOT()(HSQLDB - bitwise operation method BITANDNOT() is not found)

新的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停止定期执行CHEKPOINT操作,日志文件也在不断增长(HSQLDB is stop doing periodic CHEKPOINT operation and log files is keep growing)

在.log的大小达到其限制之后,在提交到数据库的所有连接时执行CHECKPOINT操作。 您可能有一个尚未提交的连接。 您可以检查INFORMATION_SCHEMA.SYSTEM_SESSIONS表并查看事务中是否存在会话。 您可以使用ALTER SESSION语句重置此类会话。 http://www.hsqldb.org/doc/2.0/guide/sessions-chapt.html After the size of the .log reaches its limit, the CHE...

我的HSQLDB上的更改不一致(Changes on my HSQLDB are inconsistent)

HSQLDB对用户名和密码强制区分大小写。 您需要使用相关的引号字符作为用户名和密码,以便在您输入的确切情况下进行。 create user "internal_admin" password 'somepassword' ADMIN; HSQLDB enforces case sensitivity for user names and passwords. You need to use relevant quote characters for user name and password...

如何更改HSQLDB服务器侦听的端口(How to change port that HSQLDB server listens on)

如果更改服务器上的默认端口,则需要在连接URL中指定端口: jdbc:hsqldb:hsql://localhost:9137/webappdb If you change the default port on the server, you need to specify the port in the connection URL: jdbc:hsqldb:hsql://localhost:9137/webappdb

为什么ArrayDeque类在pollFirst方法中使用按位运算?(Why the ArrayDeque class use bitwise operation in the pollFirst method?)

看看初始化代码 - Deque表示为一个大小总是为2的幂的数组: 195 public ArrayDeque(int numElements) { 196 allocateElements(numElements); 197 } 124 private void allocateElements(int numElements) { 125 int initialCapacity = MIN_INITIAL_CAPACITY; 126 ...

表没有找到Hibernate和HSQLDB(Table Not Found with Hibernate and HSQLDB)

那么,桌子真的在那里吗? 为Hibernate启用SQL输出并根据实际的数据库模式进行检查。 您的重构可能已经过时(实体和表格已重命名;命名查询未更新)。 或者你可能在类路径的某个地方有一个较旧的类,导致读取错误的注释。 Well, is the table actually there? Enable SQL output for Hibernate and check it against the actual database schema. Your refactoring may hav...

不导出Hibernate + HSQLDB架构(Hibernate + HSQLDB schema is not exported)

USER是一个特殊的函数名称,不应该用于您的实体。 I solved the problem. Hibernate properties in should be precided by "hibernate.". Following change did the trick: <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDi...

相关文章

更多

fw:Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】

转自:http://m.oschina.net/blog/81771 Hadoop、Pig、Hive、 ...

顶 Hadoop、Pig、Hive、Storm、NOSQL 学习资源收集【Updating】

(一)hadoop 相关安装部署 1、hadoop在windows cygwin下的部署: ht ...

gui求jtapi高手T_T

小弟今年刚毕业,上了一个星期班,老大要我用jtapi写一个监控程序,弄了两天了,头很大啊。 有一部座 ...

webservice可不可以实现动态的返回类型:<T> List<T> getList(T a)

webservice可不可以实现动态的返回类型 例如: &lt;T&gt; List&lt;T&g ...

收集的英语资源(不断更新)

常用谚语100句 托福100句 网友300句 英文学习网站 常用谚语100 1.Health is h ...

Don’t work. Be hated. Love someone.

http://halfhalf.posterous.com/dont-work-be-hated-lo ...

Git 常用命令 - 不断更新中

一、git clone git clone 支持本地和远程repository,其格式如下 ...

Hadoop出现元数据不能更新且SNN合并失效

问题表现: NameNode 保存edits文件 停留在5.3号凌晨。SNN执行合并文件报 空指针错误 ...

javax.imageio.IIOException: Can't create output stream!的解决方案

ImageIO.write(image, "jpeg", response.getOutputStre ...

最新问答

更多

如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)

您可以简单地在模型上使用toJSON方法并从对象中获取密钥。 Ember.keys(model.toJSON()) 请注意,不会返回关键字。 You can simply use toJSON method on model and get the keys from object. Ember.keys(model.toJSON()) Note that will not return you keys for relations.

maven中snapshot快照库和release发布库的区别和作用

在使用maven过程中,我们在开发阶段经常性的会有很多公共库处于不稳定状态,随时需要修改并发布,可能一天就要发布一次,遇到bug时,甚至一天要发布N次。我们知道,maven的依赖管理是基于版本管理的,对于发布状态的artifact,如果版本号相同,即使我们内部的镜像服务器上的组件比本地新,maven也不会主动下载的。如果我们在开发阶段都是基于正式发布版本来做依赖管理,那么遇到这个问题,就需要升级组件的版本号,可这样就明显不符合要求和实际情况了。但是,如果是基于快照版本,那么问题就自热而然的解决了

arraylist中的搜索元素(Search element in arraylist)

您正在尝试搜索主题的arraylist,您需要编写一个小函数来将代码字符串与类的相应字符串进行比较。 您可以通过将其添加到主题类来完成此操作。 示例: @Override public boolean equals(String code) { return code.equals(this.); } 并将比较更改为需要匹配您匹配的代码的成员。 编辑:更简单的方法是将现有代码更改为: if (s.code.equals(codeNo[i])) //

从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)

这当然是一个重复的问题 。 编辑 : 循环执行后, $gg将指向列表中的最后一个值(在本例中为1002)。 我相信您正在尝试访问的用户选择的的值,可以通过以下方式完成: 在edit.php中 : "; while

Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)

不可以。您只能作为图片的共享提供商。 对于其他所有内容,您可以为开发人员提供一个可以与您的应用关联的URI方案 ,因此如果他们决定与您分享内容,则可以稍后调用它。 但是,这不是系统范围的共享扩展。 No. You can only act as a share provider for pictures. For everything else, you can give developers an URI scheme that they can associate with your app

如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)

首先,对于你的路径字符串,你应该将r前缀作为原始字符串,并且\不被视为转义字符。 其次,您可以使用datetime.datetime.now()来获取当前时间,然后使用strftime()来填充日期。 示例 - import datetime path = r'C:\soa11g\New\abc_%s.zip' % datetime.datetime.now().strftime('%d%m%Y') connect('weblogic','welcome','t3://localhost:700

如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)

请尝试以下方法: $messages = $user->contact_messages()->paginate(10); Try the following: $messages = $user->contact_messages()->paginate(10);

从iframe访问父页面的id元素(accessing id element of parent page from iframe)

您试图在父窗口上使用jQuery,尽管它没有在该上下文中定义。 它仅在子文档中定义。 而是更改您的子iframe脚本以在父窗口的元素上调用jQuery。 这是一个例子: 父文件 Parent click

linux的常用命令干什么用的

linux和win7不一样,win7都图形界面,都是用鼠标来操作打开,解压,或者关闭。而linux是没有图形界面的,就和命令提示符一样的一个文本框,操作linux里的文件可没有鼠标给你用,打开文件夹或者解压文件之类的操作都要通过linux常用命令。

Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)

问题是Feign接口中的方法不能有多个“通用”参数。 您可以拥有任意数量的标头参数,但不能多于一个主体。 由于@RequestBody没有做任何事情,因此除了HttpServletRequest请求变量之外,它不被视为标题而是另一个变量。 所以我不得不改变我的业务逻辑只有一个参数。 The problem was that a method in Feign interface cannot have more than one 'general' argument. you can have