周总结web未完成的代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>开心消消乐</title>
<script type="text/javascript">
var row=2;
var col=2;
var currImagno=-1;
var lastImagno=-1
var myArray=new Array(100);
var iss=new Array(100);
var count=0;
function mySort()
{
return Math.random()>0.5;
}
function init(row, col)
{
//0--12
for(var k=0;k<2*(col*row);k++)
{
myArray[k]=( Math.round( Math.random()*17 )+1);
myArray[k+(col*row)]=myArray[k];
iss[k]=false;
}
myArray.sort(mySort);
var str='<table name="myT" border="1" width="300" height="300">';
for(var i=1;i<=row;i++)
{
str+="<tr>";
for(var j=0;j<col;j++)
{
str+="<td onclick='judge("+ ((i-1)*col +j )+");'>"
str +="<img id='img_"+ ((i-1)*col +j )+"' src='photo/image0.gif'/>"
str+="</td>";
}
str+="</tr>";
}
str+= "</table>"
document.getElementById("mt").innerHTML=str;
}
function createTable()
{ init(row,col);
document.getElementById("next").value="下一关"
row++;
col++;
}
function judge(temp)
{
//temp 表格单元格编号 1---12
lastImagno=currImagno;
currImagno=temp;
var currImg=document.getElementById("img_"+temp);
currImg.src="photo/image"+myArray[temp]+".gif";
if(lastImagno>=0){
if(myArray[currImagno]==myArray[lastImagno]){
currImagno=lastImagno=-1;
iss[lastImageno]=true;
count++;
if(count=row*col){
alert("成功");}
}
else
{
var lastimg=document.getElementById("img_"+lastImagno);
currImg.src="photo/image0.gif";
iss[temp]=false;
}
}
}
</script>
</head>
<body>
<div id="mt">开心消消乐</div>
<input id="next" type="button" value="开心消消乐" onClick="createTable();"/>
</body>
</html>
posted on 2016-04-07 20:57 DingDingBoom 阅读(166) 评论(2) 编辑 收藏 举报