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

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

各位大神幫下忙吧,我想問下:點擊取消按鈕怎么回到點擊按鈕界面,我點擊取消他顯示的也是"要努力了",我空值點擊確定他也顯示的是“要努力了”,要怎么才能空值情況下提示“請輸入分數(shù)”

?<script type="text/javascript">
? function rec(){
?? ?var score; //score變量,用來存儲用戶輸入的成績值。
?? ?score =prompt("請輸入你的分數(shù)")?????????????? ;
?? ?if(score>=90)
?? ?{
?? ??? document.write("你很棒!");
?? ?}
?? ?else if(score>=75)
??? {
?? ??? document.write("不錯吆!");
?? ?}
?? ?else if(score>=60)
??? {
?? ??? document.write("要加油!");
??? }
??? else
?? ?{
?????? document.write("要努力了!");
?? ?}
? }
? </script>

正在回答

10 回答

<script type="text/javascript">

? function rec()

? {

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

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

if(score>=90)

{

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

}

else if(score>=75)

? ? {

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

}

else if(score>=60)

? ? {

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

? ? }

? ?else if(score>=0&&score!=null)

{

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

}

else if(score==null)

{

? ? ? ?document.write(value);

}

? }

? </script>

這樣點取消就回到按鈕"點擊我,對成績做評價!"

0 回復 有任何疑惑可以回復我~

https://img1.sycdn.imooc.com//5c8d06c60001195d09070838.jpg只需要加個判斷,判斷輸入結(jié)果是否為空字符串或者null就行了,如果是的話再走一遍方法就可以了



0 回復 有任何疑惑可以回復我~

?function rec(){

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

score = prompt("你的分數(shù):") ;

? ? if(score==null||score=="")return false; //對返回null和空值的情況作出判斷

if(score>=90)

{

? ? ? ? document.write("非常棒!");

}

else if(score>=75)

? ? {

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

}

else if(score>=60)

? ? {

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

? ? }

else if(score>=0)

{

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

}

? ? else{

? ? ? ? document.write("輸入的格式有誤!");

? ? }


? }


0 回復 有任何疑惑可以回復我~

搞定沒 我這個可以幫你搞定

<!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變量,用來存儲用戶輸入的成績值。
?? ?score =?? prompt('您的成績','');???????????? ;
?? ?if(score>=90)
?? ?{
?? ??? document.write("你很棒!");
?? ?}
?? ?else if(score>=75)
??? {
?? ??? document.write("不錯吆!");
?? ?}
?? ?else if(score>=60)
??? {
?? ??? document.write("要加油!");
??? }
??? else if(score =='' || score == null)
?? ?{
?? ??? alert('請輸入分數(shù)!');
?? ?}
?? ?else if(score <60)
?? ?{
?????? document.write("要努力了!");
?? ?}
? }
? </script>
</head>
<body>
??? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>

1 回復 有任何疑惑可以回復我~

<!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變量,用來存儲用戶輸入的成績值。

score = prompt("你考了多少分","60") ? ? ? ? ? ? ? ;

if(score>=90)

{

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

}

else if(score>=75)

? ? {

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

}

else if(score>=60)

? ? {

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

? ? }

else if(score==null){

? ?alert("別點取消!")

}

else if(score==""){

? ?alert("別空著,請輸入分數(shù)!")

}

? ? else

{

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

}

? }

? </script>

</head>

<body>

? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />

</body>

</html>


0 回復 有任何疑惑可以回復我~

很簡單,如果你沒有輸入按確認,他就會返回一個空字符串"",而不是null,這里注意一下就行了

0 回復 有任何疑惑可以回復我~

這里好像是固定的 你可以用記事本試試 按照你的想法 要定義兩個函數(shù)方法 一個是讓用戶輸入成績的,另一個是判斷分數(shù)的 在這里 如果輸入的分數(shù)==null 就調(diào)用第一個函數(shù)方法.....

0 回復 有任何疑惑可以回復我~

<!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變量,用來存儲用戶輸入的成績值。

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

? ? if(score==null){

? ? ? ?document.write("請輸出分數(shù)!");? ??

? ? }

? ? else if(score>=90)

{

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

}

else if(score>=75)

? ? {

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

}

else if(score>=60)

? ? {

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

? ? }

? ? else

{

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

}

? }

? </script>

</head>

<body>

? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />

</body>

</html>


弄好了,這里 if score=null ,應(yīng)該寫成if score==null就好了。

0 回復 有任何疑惑可以回復我~
#1

苗洋

改成 if score==null 也不對把?
2018-09-29 回復 有任何疑惑可以回復我~
#2

比天空更遠 回復 苗洋

跑出來了你可以試一下,應(yīng)該對吧
2018-09-29 回復 有任何疑惑可以回復我~

<!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變量,用來存儲用戶輸入的成績值。

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

? ? if(score=null){

? ? ? ?document.write("請輸出分數(shù)!");? ??

? ? }

? ? else if(score>=90)

{

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

}

else if(score>=75)

? ? {

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

}

else if(score>=60)

? ? {

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

? ? }

? ? else

{

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

}

? }

? </script>

</head>

<body>

? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />

</body>

</html>



我是這樣寫的,但也是不行,有沒有前輩幫幫忙!

或者是讓繼續(xù)跳出alert,警告請輸入分數(shù)!

多謝!

0 回復 有任何疑惑可以回復我~
#1

江戶川柯南_qq

你這樣也不行,沒有輸入返回的是空字符串"",按取消才是返回null
2018-09-30 回復 有任何疑惑可以回復我~

語法:

prompt(str1,?str2);

參數(shù)說明:

str1:?要顯示在消息對話框中的文本,不可修改(也就是input中value的值)
str2:文本框中的內(nèi)容,可以修改

我也是剛學的,不知道這么理解對不對,但愿可以幫到你


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

各位大神幫下忙吧,我想問下:點擊取消按鈕怎么回到點擊按鈕界面,我點擊取消他顯示的也是"要努力了",我空值點擊確定他也顯示的是“要努力了”,要怎么才能空值情況下提示“請輸入分數(shù)”

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

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

幫助反饋 APP下載

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

公眾號

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