【发布时间】:2023-04-09 05:32:02
【问题描述】:
我做了一个匹配游戏的项目。在所有卡片匹配和游戏结束后,会弹出一个祝贺模式。但是我不知道为什么在点击再次播放按钮后它没有关闭。
这里是模态窗口的 index.html
<!--Add Bootstrap Modal Alert Window-->
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal-label" aria-hidden="true">
<div class="modal-dialog">
<!--Modal Content-->
<div class="modal-content">
<!--Modal Header-->
<div class="modal-header">
<h4 class="modal-title" id="myModal-label">Congratulations!!!</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<!--Modal Body-->
<div class="modal-body">
<p id="myText"></p>
</div>
<!--Modal Footer-->
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-success btn-default" onclick="gameStart(), $rating.removeClass('fa-star-o').addClass('fa-star');">Play Again!</button>
</div> <!--modal footer-->
</div> <!--modal-content-->
</div> <!--modal-dialog-->
</div> <!--modal-->
还有用于 Modal 的 javascript:
function gameOver(moves, score) {
$('#myText').text(`Time: ${second} Seconds, Your Move: ${moves} Moves, Total
Score: ${score}, Well done!!!`);
$('#myModal').toggle();
}
if (totalCard === match) {
rating(moves);
let score = rating(moves).score;
setTimeout(function () {
gameOver(moves, score);
},800);
}
这是我的配对游戏项目的链接:
【问题讨论】:
-
不,它不起作用。
标签: javascript jquery css bootstrap-4