为什么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)[2022-04-10]
删除“(引号) 默认情况下,如果没有引号,则名称不区分大小写。 但是您将表名放在引号之间,因此它们完全按照区分大小写进行注册。 然后两个表名称不同,HSQLDB将不匹配。 这将有效: import java.sql.*; public class Main { public static void main(String[] args) throws Exception { Connection c = DriverManager.getConnection("jdbc:hsqldb:mem: ... -
Java 8增加了将lambda转换为匿名交集的能力。 返回类型既是Comparator
又是Serializable 参考: assylias的答案在这里 文档 注意: Java有时会为运算符添加新的语法含义,以保持向后兼容性。 Java 8 adds the ability to cast the lambda into an anonymous intersection. The return type is both a Comparator and Serializable Refere ... -
您的示例可以像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 (SELECT ...
-
HSQLDB - 未找到按位操作方法BITANDNOT()(HSQLDB - bitwise operation method BITANDNOT() is not found)[2022-03-25]
新的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. -
在.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 CHECKPOI ...
-
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 to m ...
-
如果更改服务器上的默认端口,则需要在连接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?)[2022-01-04]
看看初始化代码 - Deque表示为一个大小总是为2的幂的数组: 195 public ArrayDeque(int numElements) { 196 allocateElements(numElements); 197 } 124 private void allocateElements(int numElements) { 125 int initialCapacity = MIN_INITIAL_CAPACITY; 126 // Fi ... -
那么,桌子真的在那里吗? 为Hibernate启用SQL输出并根据实际的数据库模式进行检查。 您的重构可能已经过时(实体和表格已重命名;命名查询未更新)。 或者你可能在类路径的某个地方有一个较旧的类,导致读取错误的注释。 Well, is the table actually there? Enable SQL output for Hibernate and check it against the actual database schema. Your refactoring may have bee ...
-
USER是一个特殊的函数名称,不应该用于您的实体。 I solved the problem. Hibernate properties in should be precided by "hibernate.". Following change did the trick:
org.hibernate.dialect.HSQLDialect ...