<style>
.no{
display: none;
}
.yes{
display:inline-block;
}
</style>
</head>
<body>
<input type="text" placeholder="请输入0-100你所猜到的数字" id="text">
<button id="btn">猜一猜</button>
<button id="btn2" class="no">再来一次?</button>
<p id="p"></p>
</body>
<script>
var oipt = document.getElementById("text");
var p = document.getElementById("p");
var obtn = document.getElementById("btn");
var obtn2 = document.getElementById("btn2")
var x = parseInt(Math.round(Math.random() * 100));
obtn.onclick = function(){
if(oipt.value > x){
p.innerHTML="猜大了";
obtn2.className="no";
}else if(oipt.value < x){
p.innerHTML="猜小了";
obtn2.className="no";
}else if(oipt.value==x){
p.innerHTML = "恭喜你,猜对了";
obtn2.className="yes";
}
}
obtn2.onclick = function () {
x = parseInt(Math.round(Math.random() * 100)) ;
p.innerHTML = " ";
oipt.value = " ";
obtn2.className = "no";
};
</script>