📄 完成按钮.htm
字号:
<html>
<head>
<script>
<!--
var figs=new Array(15); //存放按钮的显示数字
var flag=false; //游戏是否已经开始
function deal(){
flag=true;
for(i=0;i<15;i++)
{
figs[i]=Math.floor(Math.random() * 15)+1;
for(j=0;j<i;j++)
if(figs[i]==figs[j])
{i--; break;}
}
for(i=0;i<15;i++)
{
if(figs[i]<10) figs[i]=" "+figs[i]+" ";
else figs[i]=" "+figs[i];
document.forms[0].elements[i].value=figs[i];}
}
var h_ind=15;
function move(ind){
if(flag&&(ind==(h_ind-1)||ind==(h_ind+1)||ind==(h_ind-4)||ind==(h_ind+4)))
{
with(document.forms[0].elements[h_ind])
{ value=document.forms[0].elements[ind].value;
style.visibility="visible"; }
document.forms[0].elements[ind].style.visibility="hidden";
h_ind=ind;}
}
function suc(){
for(i=1;i<16;i++)
if(document.forms[0].elements[i-1].value!=i)
{alert("游戏还没完成!!");
break;}
if(i==16)
alert("成功了!好样的!");
}
-->
</script>
</head>
<body>
<form name="form1"><p>
<input type="button" value=" 1 " name="B1" onClick="move(0);"><input type="button" value=" 2 " name="B2" onClick="move(1);"><input type="button" value=" 3 " name="B3" onClick="move(2);"><input type="button" value=" 4 " name="B4" onClick="move(3);"><br>
<input type="button" value=" 5 " name="B5" onClick="move(4);"><input type="button" value=" 6 " name="B6" onClick="move(5);"><input type="button" value=" 7 " name="B7" onClick="move(6);"><input type="button" value=" 8 " name="B8" onClick="move(7);"><br>
<input type="button" value=" 9 " name="B9" onClick="move(8);"><input type="button" value=" 10" name="B10" onClick="move(9);"><input type="button" value=" 11" name="B11" onClick="move(10);"><input type="button" value=" 12" name="B12" onClick="move(11);"><br>
<input type="button" value=" 13" name="B13" onClick="move(12);"><input type="button" value=" 14" name="B14" onClick="move(13);"><input type="button" value=" 15" name="B15" onClick="move(14);"><input type="button" value=" 16" name="B16" style="visibility:hidden" onClick="move(15);">
<p><input type="button" value=" 开始 " name="B17" onClick="deal();"><br>
<input type="button" value=" 完成 " name="B17" onClick="suc();"><br>
<input type="button" value=" 重玩 " name="B18"></p>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -