此函数比较两张点击图片的源地址。如果它们相同,分数增加 2 分,方块隐藏。如果不同,分数减少 2 分,图片隐藏。$("#score").text(score) 会实时更新 HTML 文件中 <p>The current number of points is <span id="score">0</span></p> 部分的分数显示。
实现开始按钮功能
在这一步中,你将实现开始按钮的功能。按照以下步骤完成此步骤:
打开 js/index.js 文件。
在 startGame() 函数中,添加以下代码,以便在点击开始按钮时显示然后隐藏方块上的图像:
function startGame() {
$(".img-box img").show(1000, function () {
$(this).hide(1000);
});
}
We use cookies for a number of reasons, such as keeping the website reliable and secure, to improve your experience on our website and to see how you interact with it. By accepting, you agree to our use of such cookies. Privacy Policy