第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

prompt中,如果要判斷是否輸入怎么辦?以下是代碼

如果不輸入內(nèi)容,prompt接收的值并不是null。

<html>

<head>

<title>無標(biāo)題文檔</title>

<script type="text/javascript">

function rec(){

var score=prompt("請輸入你的分?jǐn)?shù)");

if(score!=null){

if(score>=98)

document.write("你很棒!");

else if(score>=75)

document.write("不錯");

else if(score>=60)

document.write("要jiayou");

else

document.write("要努力");

}

else

alert("輸入內(nèi)容為空?。?!");//判斷無效

}

</script>

</head>


<body>

<input name="button" type="button"onClick="rec()"

value="點擊我,對成績做評價" />

</body>

</html>


正在回答

2 回答

?我是這么寫的

function rec(){

var score; //score變量,用來存儲用戶輸入的成績值。

score =prompt("請輸入你的成績:"); ? ? ? ? ? ? ? ?;

if(!score)

? ? {

? ? ? ?document.write("請輸入內(nèi)容")

}

? ? else if(score>=90)

{

? document.write("你很棒!");

}

else if(score>=75)

? ? {

? document.write("不錯吆!");

}

else if(score>=60)

? ? {

? document.write("要加油!");

? ? }

? ? else

{

? ? ? ?document.write("要努力了!");

}

? }


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

champion666 提問者

我知道怎么寫了,把null改成: “”這樣就可以了
2016-12-20 回復(fù) 有任何疑惑可以回復(fù)我~

<html>

<head>

<title>無標(biāo)題文檔</title>

<script type="text/javascript">

function rec(){

????var score=prompt("請輸入你的分?jǐn)?shù)");

????if(score!=null){

????????if(score>=98)

????????????document.write("你很棒!");

????????else if(score>=75)

????????????document.write("不錯");

????????else if(score>=60)

????????????document.write("要jiayou");

????????else

????????????document.write("要努力");

????}

????else

????????var tem=confirm("你還沒有輸入成績!");

????????alert(tem);


}

</script>

</head>


<body>

<input name="button" type="button"onClick="rec()"

value="點擊我,對成績做評價" />

</body>

</html>



0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

champion666 提問者

謝謝你的回答,可是依然不能實現(xiàn),當(dāng)不輸入任何數(shù)據(jù)提交的時候,最后依舊是“要努力”
2016-12-19 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

prompt中,如果要判斷是否輸入怎么辦?以下是代碼

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號