j**ascript最简单的连连看
以容已经在ie8 chrome通过,其它浏览器未人测试。<!doctype html><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>简单的连连看</title><style type="text/css">table{background:black;margin:auto}td{background:white;cursor:pointer;width:150px;height:150px;text-align:center;vertical-align: middle;}td img {height: 100px;width: 100px;border:2px solid #ccc}td .theimg{border:2px solid red}.**{height:45px;width:420px;margin:20px auto}.** font{color:red;font-size: 16px;font-weight:bold;}.** label{margin-left:20px}.** span{color:#090;font-weight:bold;}</style></head><body></body><h3>简单连连看</h3><div id="box"></div><div class="**"><input type="button" value="重新开始" onclick="init()"><label id="**">连连看</label></div><script type="text/j**ascript">/*百度知道: wjsl原创*/function init(){var box=document.getelementbyid("box"),clickcount=0,theimg,thesrc,**=document.getelementbyid("**");var imgsrc=["files/5(1).jpg","files/4(1).jpg","files/5(1).jpg","files/4(1).jpg"],tab="<table cellspacing='10' cellpadding=''><tr>",arr=[],imgl;while(imgl=imgsrc.length){tab+="<td><img src='"+imgsrc.splice(math.round(math.random()*(imgsrc.length-1)),1).tostring()+"' /></td>"if(!(imgl%3))tab+="</tr><tr>"}tab+="</tr></table>"box.innerhtml=tabbox.onclick=function(event){var ele=(event||window.event).srcelement,src=ele.src,str;clickcount+=1if(ele.tagname!="img")return falseif(ele.classname=="theimg"){**.innerhtml="点击重复";return false}ele.classname="theimg"if(clickcount>1){if(src==thesrc){str="<span>匹配成功</span>"ele.parentnode.innerhtml="";theimg.parentnode.innerhtml=""}else{str="匹配错误"}var i=0,imgs=box.getelement**ytagname("img"),imgsl=imgs.lengthif(imgsl>0){for(;i<imgsl;i++){imgs[i].classname=""}}else{str="<font>恭喜你清除完成</font>"}theimg=""clickcount=0**.innerhtml=str}else{theimg=elethesrc=src}}}init()</script></html> 20210311