<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<title>if...else</title>
<script?type="text/JavaScript">
function?zz(){
var?myage;
????myage?=prompt("你的年齡")
if(myage<=44)
??{document.write("青年");}
else?if(myage<=59)?
??{document.write("中年人");}
else?if??(myage<=89)
??{document.write("老年人");}
else????????
??{document.write("長壽老年人");}
else{document.write("永遠(yuǎn)十八");}
}
</script>
</head>
<body>
????<from>
????????<input?type="button"?value="點(diǎn)次測試年齡段"?onclick="zz()">
????????</from>
</body>
</html>
2018-03-18
就因?yàn)樽詈筮@個(gè)分號,使用英文的就對了
2018-03-11
高手這個(gè)空格怎么弄的???
試了半天才發(fā)現(xiàn)的
2017-11-28
else????????
??{document.write("長壽老年人");}
else{document.write("永遠(yuǎn)十八");}
這里錯(cuò)了,長壽老年人這塊判斷還要加一個(gè)條件才可以
else?if(myage<=99)
??{document.write("長壽老年人");}
else{document.write("永遠(yuǎn)十八");}這個(gè)最后的分號是在英文輸入法的分號;,不是中文輸入法的分號;
2017-11-16
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if...else</title>
<script type="text/JavaScript">
function qwe(){
var myage=prompt("你的年齡");
if(myage<=44){
document.write("青年");
}
else if(myage<=59){
document.write("中年人");
}
else if(myage<=89){
document.write("老年人");
}
else if(myage>89){
document.write("長壽老年人");
}else{
document.write("永遠(yuǎn)十八")
}
}
</script>
</head>
<body>
? ? <from>
? ? <input type="button" value="點(diǎn)擊測試年齡"? onclick="qwe()"/>? ?
? ? </from>
</body>
</html>