javascript基础-黑白反斗棋
来源:互联网 发布:男士护肤品品牌 知乎 编辑:程序博客网 时间:2024/04/29 16:34
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script>function demo(Obj){var tdId=Obj.id;var table=document.getElementById("t");var tdIdArray=tdId.split("-");var x=parseInt(tdIdArray[0]);var y=parseInt(tdIdArray[1]);changeBgColor(tdId);if(x-1>=0){changeBgColor((x-1)+"-"+y);}if(x+1<=4){changeBgColor((x+1)+"-"+y);} if(y-1>=0){ changeBgColor(x+"-"+(y-1));} if(y+1<=4){changeBgColor(x+"-"+(y+1));}success();} function changeBgColor(id){if(document.getElementById(id).bgColor=="#000000"){document.getElementById(id).bgColor="#ffffff"; }else if(document.getElementById(id).bgColor=="#ffffff"){document.getElementById(id).bgColor="#000000"; }}function success(){var flag=true;for(i=0;i<5;i++){for(j=0;j<5;j++){if(document.getElementById(i+"-"+j).bgColor!="#ffffff"){flag=false; }}}if(flag){alert("你赢了!");}} </script></head><body><table id="t" border="1" width="500" height="500"> <tr> <td bgcolor="#000000" id="0-0" onclick="demo(this)"></td> <td bgcolor="#000000" id="0-1" onclick="demo(this)"></td> <td bgcolor="#000000" id="0-2" onclick="demo(this)"></td> <td bgcolor="#000000" id="0-3" onclick="demo(this)"></td> <td bgcolor="#000000" id="0-4" onclick="demo(this)"></td> </tr> <tr> <td bgcolor="#000000" id="1-0" onclick="demo(this)"></td> <td bgcolor="#000000" id="1-1" onclick="demo(this)"></td> <td bgcolor="#000000" id="1-2" onclick="demo(this)"></td> <td bgcolor="#000000" id="1-3" onclick="demo(this)"></td> <td bgcolor="#000000" id="1-4" onclick="demo(this)"></td> </tr> <tr> <td bgcolor="#000000" id="2-0" onclick="demo(this)"></td> <td bgcolor="#000000" id="2-1" onclick="demo(this)"></td> <td bgcolor="#000000" id="2-2" onclick="demo(this)"></td> <td bgcolor="#000000" id="2-3" onclick="demo(this)"></td> <td bgcolor="#000000" id="2-4" onclick="demo(this)"></td> </tr> <tr> <td bgcolor="#000000" id="3-0" onclick="demo(this)"></td> <td bgcolor="#000000" id="3-1" onclick="demo(this)"></td> <td bgcolor="#000000" id="3-2" onclick="demo(this)"></td> <td bgcolor="#000000" id="3-3" onclick="demo(this)"></td> <td bgcolor="#000000" id="3-4" onclick="demo(this)"></td> </tr> <tr> <td bgcolor="#000000" id="4-0" onclick="demo(this)"></td> <td bgcolor="#000000" id="4-1" onclick="demo(this)"></td> <td bgcolor="#000000" id="4-2" onclick="demo(this)"></td> <td bgcolor="#000000" id="4-3" onclick="demo(this)"></td> <td bgcolor="#000000" id="4-4" onclick="demo(this)"></td> </tr> </table></body></html>
2 0
- javascript基础-黑白反斗棋
- jQuery-黑白反斗棋
- javascript-黑白反斗棋选关模式
- jQuery-制作黑白反斗棋页面
- jQuery-黑白反斗棋选关模式
- 用java做的一个小游戏—黑白反斗棋(适合菜鸟)
- HUV黑白翻转棋
- JavaScript输出各色系随机颜色【红绿蓝青黄紫、黑白、全彩】
- JavaScript分类显示随机颜色【红绿蓝青黄紫、黑白、全彩】
- 黑白翻转棋算法java实现
- □ 影片名:《反斗四条狗》(2064)
- Justin Frankel:Winamp的反斗奇星
- 从黑白到黑白
- javaScript基础
- JAVASCRIPT 基础
- JavaScript基础
- JAVASCRIPT基础
- JavaScript 基础
- POJ3169 Layout (差分约束)
- javascript基础-翻牌游戏
- Android PopupWindow详解
- javascript基础-猜拳游戏
- 排序算法的时间复杂度和空间复杂度
- javascript基础-黑白反斗棋
- jQuery-制作黑白反斗棋页面
- jQuery-黑白反斗棋
- 数据结构-冒泡排序算法
- HDU-2012-素数判定【打表】
- 斐波那契额序列
- 数据结构-二分查找
- 数据结构-快速排序算法
- 数据结构-归并排序