Javascriptはデジタルゲームを当てます.
5256 ワード
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<div style="width:200px;height:200px;border:dashed;background-color:darkseagreen;border-width:1px;">
<p>1. 0 100 <br />2. <br />3. result </p>
<label id="lblResult" style="width:30px;background-color:crimson"> </label>
<br />
<label id="lblCount" style="background-color:darkcyan"> :0</label>
<br />
<input type="text" id="txtNum" onchange="getResult()" ondblclick="CaiShu()" />
<br />
<label id="lblDebug">Coded By Phoenix©2016</label>
<button hidden="hidden" id="btnReset" onclick="reset()"> </button>
</div>
<script>
var shuzhi = parseInt(Math.random() * 100);//
var cishu = 0;
//document.getElementById("realValue").innerHTML = shuzhi;
var lblResult = document.getElementById("lblResult");
var lblDebug = document.getElementById("lblDebug");
var txtNum = document.getElementById("txtNum");
function CaiShu() {
var num = txtNum.value;//
//alert(num);
if (shuzhi>num) {
lblResult.innerHTML = " ";
cishu = cishu + 1;
txtNum.textContent = "";
}
if(shuzhi<num) {
lblResult.innerHTML = " ";
cishu = cishu + 1;
txtNum.textContent = "";
}
if(shuzhi==num)
{
lblResult.innerHTML = " ";
document.getElementById("btnReset").hidden = null;
}
//
document.getElementById("lblCount").innerHTML =" "+ cishu;
}
function reset() {
shuzhi = parseInt(Math.random() * 100);
cishu = 0;
document.getElementById("btnReset").hidden = "hidden";
document.getElementById("txtNum").value = "";
document.getElementById("lblResult").innerHTML = " ";
document.getElementById("lblCount").innerHTML = 0;
}
function getResult() {
var result = txtNum.value == "result";
//lblDebug = result;
if (result) {
txtNum.value = shuzhi;
}
}
</script>
</body>
</html>