<input type="text" id="inp1">
<button id="btn">结果</button>
<input type="text" id="inp2">
<script>
btn.onclick = function () {
var v = inp1.value;
console.log(v)
if (v !== '') {
if (v >= 0 && v <= 100) {
if (v < 60) {
var a = '不及格';
} else if (v < 70) {
var a = '及格';
} else if (v < 80) {
var a = '良好';
}else if (v <= 100) {
var a = '优秀';
}
inp2.value = a;
} else {
alert('输入不合法')
}
} else {
alert('不能为空')
}
}
</script>
转载请注明原文地址:https://ipadbbs.8miu.com/read-4072.html