如果用户在记忆游戏中点击同一张卡片,我试图不允许调用匹配。虽然它仍然允许
我试过跟踪鼠标并试图不让它点击同一张卡片。
<script>
var OpenCard = [];
if (OpenCard.length == 2){
const CardType1 =
OpenCard[0].querySelector('i').classList.item(1)
const CardType2 =
OpenCard[1].querySelector('i').classList.item(1)
console.log(CardType1, CardType2);
movespassed();
check_stars();
//compares two cards and checks for a match
if (CardType1 == CardType2){
OpenCard.forEach(function(card){
card.classList.add('match')
});
OpenCard = []
game_score++;
console.log(game_score);
}
//if cards don't match close them
else{
console.log("i'm here")
setTimeout(function(){
OpenCard.forEach(function(card){
card.classList.remove('show', 'open')
})
OpenCard = []
},200);
}
</script>function(c){
OpenCard.push(card);
track.push(card);
card.classList.add('show', 'open');
梦里花落0921
相关分类