<!DOCTYPE html>
<html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><body> <input type="text" id="scf"> <input type="submit" id="pf" value="评分"> <div id="txt"></div><script>
var scf=document.getElementById("scf"); var pf=document.getElementById("pf"); pf.οnclick=function(){ var n=scf.value; if(n=="") {txt.innerHTML="请输入一个数字" return; } if(isNaN(n)||(n<0||n>100)) {txt.innerHTML="数据非法" return; } if(n>=0&&n<=100) { if(n>=90){ txt.innerHTML="优秀"; } else if(n>=75){ txt.innerHTML="良好"; } else if(n>=60){ txt.innerHTML="及格"; } else if(n>=0) { txt.innerHTML="不及格"; } } } </script></body></html>