我正在处理的页面位于keeptheinternetpure.com/memory.html
代码位于keeptheinternetpure.com/myCode.js
样式表位于 keeptheinternetpure.com/standard.css
我正在尝试使用“选定”类获取元素的任何边框,以便在 2 个类之间快速切换,从而有效地使其动画化。我的代码目前适用于左侧表格的单元格,但是当您启动游戏并单击图标以手动将它们更改为选定的类时,它不起作用并且有一个奇怪的故障,这让我相信这是一个问题使用 clickedOn() 函数。改变类的函数是borderAnimation()。所选图块的边框应与左侧表格中的边框完全相同。
编辑:这是我的 clickedOn() 函数:
function clickedOn(index)
{
tempIndex = index;
ostream = document.getElementById('coordinates');
ostream.innerHTML = 'Row ' + (Math.floor(tempIndex / $tblcols) + 1 + ' Column ' + (Math.floor(tempIndex % $tblcols) + 1));
//if the user already clicked
if ($indexCounter >= 2)
{
//do nothing
}
else if ($theCards[index].status == "unselected")
{
$theCards[index].status = "selected";
displayStatus(index);
//if the user has guessed 1 time
if ($selectedCounter < 2)
{
//change the status to selected and save the index
$selectedCounter++;
if ($selectedCounter != 2)
{
$previousIndex = index;
$indexCounter++;
}
}
//if the user has guessed 2 times
if ($selectedCounter >= 2)
{
//if the types aren't the same
if ($theCards[$previousIndex].type != $theCards[index].type)
{
//change the status back to unselected
var a = setTimeout(function() {$theCards[index].status = "unselected"; $theCards[$previousIndex].status = "unselected"; displayStatus(index); displayStatus($previousIndex); $indexCounter = 0;}, 1000);
}
//if they are the same
else
{
//change the status to solved
setTimeout(function() {$theCards[$previousIndex].status = "solved"; $theCards[index].status = "solved"; displayStatus($previousIndex); displayStatus(index); $indexCounter = 0; $theScore+=10;}, 500);
$solved+=2;
}
if ($solved == $theCards.length)
{
setTimeout(function() {resetGame()}, 1000);
}
$selectedCounter =0;
}
}
}