Javascript jQuery在Firefox和IE上运行不好
我创建了一个网页,JavaScript代码在Chrome上运行得非常好。但当我在Firefox和IE上测试时,它有很多bug。我只是不明白为什么我的DOM元素在我尝试用jQuery更改它们的html或文本时没有受到影响Javascript jQuery在Firefox和IE上运行不好,javascript,jquery,html,firefox,Javascript,Jquery,Html,Firefox,我创建了一个网页,JavaScript代码在Chrome上运行得非常好。但当我在Firefox和IE上测试时,它有很多bug。我只是不明白为什么我的DOM元素在我尝试用jQuery更改它们的html或文本时没有受到影响 <!DOCTYPE html> <html> <head> <title>Game</title> <link rel="stylesheet" href="https:/
<!DOCTYPE html>
<html>
<head>
<title>Game</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 col-md-offset-2">
<h2>Game</h2>
</div>
<div class="col-md-2">
<h2>Score: <span id="count">0</span></h2>
</div>
</div>
<div class="row">
<div id="tablediv" class="col-md-12">
<table id="table" style="empty-cells:show;table-layout:fixed;"></table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2 id="message"></h2>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>
这只是我尝试在#count元素文本中添加1的代码部分。它在铬上工作良好。但它不会在Firefox或IE上添加1。这很奇怪。
它有很多bug
-分享它们。。。我认为你需要用jquery的几乎随处可见的文档就绪
模式来包装你的代码。你需要提供一个?FF和IE中发生了什么?控制台中是否有任何错误,或者…?是的,请提供所有代码。如果可能,创建一个JSFIDLE或codepen并发布链接。
if($('#' + i + j).html() == x) {
$('#count').text(parseInt($('#count').text()) + 1);
if(parseInt($('#count').text()) == 20) {
clearInterval(interval);
$('#message').text("You won!");
}
}