我是按照這個(gè)代碼寫的,為什么沒有彈出提問對話框,點(diǎn)擊按鈕直接輸出‘要努力了’
??<script?type="text/javascript">?function?rec(){
?var?score;?//score變量,用來存儲(chǔ)用戶輸入的成績值。 score?=?prompt("請輸入你的成績:");
if(score>=90)?{?document.write("你很棒!");?}
??else?if(score>=75)?{?document.write("不錯(cuò)吆!");?}
????else?if(score>=60)?{?document.write("要加油!");?}
???????else?{?document.write("要努力了!");?}?}?</script>?</head>?<body>?<input?name="button"?type="button"?onClick="rec()"?value="點(diǎn)擊我,對成績做評價(jià)!"?/>?</body>
2016-09-14
和你犯同樣錯(cuò)誤了,確定一下,你的
score=prompt("請輸入成績"); ?這句話是是不是英文狀態(tài)下的,尤其是括號(hào)。
2016-09-14
沒毛病,我試了五六遍一點(diǎn)問題也沒有,你可以試試onClick的C弄成小寫,不過沒啥用,因?yàn)楦緵]問題
2016-09-14
沒問題啊
2016-09-13
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type"?
content="text/html; charset=utf-8" />
<title>prompt</title>
? <script type="text/javascript">
? function rec(){
var score; //score變量,用來存儲(chǔ)用戶輸入的成績值。
score = ?prompt("你的分?jǐn)?shù)多少?") ;
if(score>=90)
{
? document.write("你很棒!");
}
else if(score>=75)
? ? {
? document.write("不錯(cuò)吆!");
}
else if(score>=60)
? ? {
? document.write("要加油!");
? ? }
? ? else
{
? ? ? ?document.write("要努力了!");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button"?onClick="rec()" value="點(diǎn)擊我,對成績做評價(jià)!" />
</body>
</html>
2016-09-13
<script type="text/javascript">
? function rec(){
var score; //score變量,用來存儲(chǔ)用戶輸入的成績值。
score = ?prompt("請輸入你的成績:");
if(score>=90)
{
? document.write("你很棒!");
}
else if(score>=75)
? ? {
? document.write("不錯(cuò)吆!");
}
else if(score>=60)
? ? {
? document.write("要加油!");
? ? }
? ? else
{
? ? ? ?document.write("要努力了!");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對成績做評價(jià)!" />
</body>
2016-09-13
把js放到body后面試試,或許關(guān)用我也不怎么懂