编写的js死活找不到问题所在,就是运行不成功

qq_31801913 qq_31801913 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,编写的js找不到问题所在,但就是不成功,各位大神运行下看怎样

html代码

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Little play</title>
<link rel="stylesheet" href="../css/play.css">
<script src="play.js"></script>

</head>
<body >

<h1>益智迷宫</h1>
<div id="gezi">
<table cellpadding="0" cellspacing="0">
<tr>
<td id="cell11">
<img src="../picture/play/07.png" alt="7" height="69" width="69">
</td>
<td id="cell12">
<img src="../picture/play/06.png" alt="6" height="69" width="69">
</td>
<td id="cell13">
<img src="../picture/play/14.png" alt="14" height="69" width="69">
</td>
<td id="cell14">
<img src="../picture/play/11.png" alt="11" height="69" width="69">
</td>
</tr>
<tr>
<td id="cell21">
<img src="../picture/play/12.png" alt="12" height="69" width="69">
</td>
<td id="cell22">
<img src="../picture/play/empty.png" alt="empty" height="69" width="69">
</td>
<td id="cell23">
<img src="../picture/play/05.png" alt="5" height="69" width="69">
</td>
<td id="cell24">
<img src="../picture/play/13.png" alt="13" height="69" width="69">
</td>
</tr>
<tr>
<td id="cell31">
<img src="../picture/play/08.png" alt="8" height="69" width="69">
</td>
<td id="cell32">
<img src="../picture/play/10.png" alt="10" height="69" width="69">
</td>
<td id="cell33">
<img src="../picture/play/01.png" alt="1" height="69" width="69">
</td>
<td id="cell34">
<img src="../picture/play/15.png" alt="15" height="69" width="69">
</td>
</tr>
<tr>
<td id="cell41">
<img src="../picture/play/04.png"alt="4" height="69" width="69">
</td>
<td id="cell42">
<img src="../picture/play/02.png" alt="2" height="69" width="69">
</td>
<td id="cell43">
<img src="../picture/play/09.png" alt="9" height="69" width="69">
</td>
<td id="cell44">
<img src="../picture/play/03.png" alt="3" height="69" width="69">
</td>
</tr>
</table>
</div>
<div>
<img src="../picture/科比/15055638_254149.jpg" id="pic">
</div>
</body>
</html>

js代码


window.onload=diaoyong;

function diaoyong(){

var biao=document.getElementById("gezi").getElementsByTagName("td");
for(var i=0;i<biao.length;i++){
var biao1=biao[i];
biao1.onclick=dianji;
}


}

function dianji(){
if(isempty(this)){
alert("请勿点击空白块!");
}

var row=this.id.charAt(4);
var col=this.id.charAt(5);

if(row>1){
var row1=Number(row)-1;
var id="cell"+row1+col;
var yinyong=document.getElementById(id);
if(isempty(yinyong)){
jiaohuan(this,yinyong);
return;
}
}
if(cow<4){
var row1=Number(row)+1;
var id="cell"+row1+col;
var yinyong=document.getElementById(id);
if(isempty(yinyong)){
jiaohuan(this,yinyong);
return;
}
}
if(col>1){
var col1=Number(col)-1;
var id="cell"+row+col1;
var yinyong=document.getElementById(id);
if(isempty(yinyong)){
jiaohuan(this,yinyong);
return;
}
}
if(col<4){
var col1=Number(col)+1;
var id="cell"+row+col1;
var yinyong=document.getElementById(id);
if(isempty(yinyong)){
jiaohuan(this,yinyong);
return;
}
}

alert("请点击空白块旁边的数字!");
}

function isempty(cell){
var image=cell.firstChild;
while(image.nodeName=="#text"){
image=image.nextSibling;
}
if(image.alt=="empty"){
return true;
}
else{
return false;
}
}

function jiaohuan(ing,kong){
var img=ing.firstChild;

while(img.nodeName=="#text"){
img=img.nextSibling;
}
var img2=kong.firstChild;
while(img2.nodeName=="#text"){
img2=img2.nextSibling;
}
ing.appendChild=img2;
kong.appendChild=img;

if(check()){
win();
}
}

function check(){
var img=document.getElementById("gezi").getElementsByTagName("img");
var num="";
for(var x=0;x<img.length;x++){
var img1=img[x];
var paixu=img1.src.substr(-6,2);
if(paixu!="ty")
num+=paixu;

}
if(num=="010203040506070809101112131415"){
return true;
}
return false;
}

function win(){
document.getElementById("pic").className="yanhua";
}



...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
qq_31801913
JavaScript 87,983 成员 224,681 内容