<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html; charset=gb2312" />
<title>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html; charset=gb2312" />
<title>JS之随机读取一条你问我答验证</title>
</head>
<body>
<divid="randomdiv">
<divid="ad1">一、选择题答案是?</div>
<divid="ad2">二、你的名字叫?</div>
<divid="ad3">三、你的最大嗜好是?</div>
<divid="ad4">四、退一步海阔天空?</div>
</div>
<ulid="randomli">
<liid="inf1">一、选择题答案是A</li>
<liid="inf2">二、我的名字叫JESON</li>
<liid="inf3">三、我的最大嗜好是PLAY!</li>
<liid="inf4">四、进一步菩萨伴侣成!</li>
</ul>
<scriptlanguage="javascript">
οnlοad=functionchange(){
var objDiv=document.getElementByIdx_x_x('randomdiv').getElementsByTagName_r("div")
varobjLi=document.getElementByIdx_x_x('randomli').getElementsByTagName_r("li")
hidAll()
showMe(Random(objDiv.length)+1)
functionRandom(k){return new Date().getSeconds()%k}
functionhidAll(){
for (vari=0;i<objLi.length;i++){
if (objLi[i].id.indexOf("inf")!=-1)
objDiv[i].style.display="none"
objLi[i].style.display="none"
}
}
functionshowMe(r){
document.getElementByIdx_x_x("ad"+r).style.display=""
document.getElementByIdx_x_x("inf"+r).style.display=""
}
}
</script>
</body>
</html>
JS之随机读取一条你问我答验证
最新推荐文章于 2024-08-18 10:54:05 发布