<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js消息模式对话框函数</title>
<script>
function input()
{
if(confirm("是否确定判断分数?")===true)
var str=prompt("");
if(str){
alert(s());
}
else
alert("");
}
function s(){
var score;
if (score <= 100 && score > 90) {
alert("高手高手,佩服佩服!");
} else if (score > 80) {
alert("8错,8错!");
} else if (score > 70) {
alert("凑合,凑合!");
} else if (score > 60) {
alert("勉强及格!");
} else {
alert("恭喜你,挂了!");
}
}
</script>
</head>
<body>
<p><a href="#" id="text1" onclick="input()">点此进入判断</a> </p>
</body>
</html>
无论输入什么 只能输出“恭喜你,挂了”
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
你好!机器人 2022-03-29 23:55关注因为你score没赋值,所以它只能走else
function input() { if(confirm("是否确定判断分数?")===true) var str=prompt(""); if(str){ alert(s()); } else alert(""); } function s(){ var score = prompt("请输入分数"); if (score <= 100 && score > 90) { alert("高手高手,佩服佩服!"); } else if (score > 80) { alert("8错,8错!"); } else if (score > 70) { alert("凑合,凑合!"); } else if (score > 60) { alert("勉强及格!"); } else { alert("恭喜你,挂了!"); } }本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 1无用