我有一张牌桌,我可以随意排序和排序,但是当我尝试从数组创建表格时,表格工作正常但是随机播放功能不再起作用。非常感谢任何帮助。
//Create table works fine with cards all in order
document.writeln('<table border = 1 align = "center" >');
for(var j=0; j<cardSet.length; j++){
if(j%13==0 && j!==0){
document.writeln('</tr><tr>');
}
document.writeln('<td ><img id = "'+ cardSet[j].id +'" src="' + cardSet[j].src + '" /></td>');
}
document.writeln('</tr></table>');
//shuffle function that works of with a manually created table but not with the code above
function shuffleCards() {
for(i=0; i<SIZE; i++)
cardSet[i] = i;
for(i=0; i<SIZE; i++) {
rndCard1 = Math.floor(Math.random()*SIZE);
rndCard2 = Math.floor(Math.random()*SIZE);
shuffleTemp = cardSet[rndCard1];
cardSet[rndCard1] = cardSet[rndCard2];
cardSet[rndCard2] = shuffleTemp;
}
for(i=0; i<cardSet.length; i++)
cardSet[i].src = document.getElementById(i).src;
}