課程
/前端開發(fā)
/JavaScript
/JavaScript進階篇
為什么我這在輸入框里什么都沒填直接點確定,彈出的是空白,點擊取消卻提示null
2016-03-17
源自:JavaScript進階篇 1-1
正在回答
參考MDN:https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
When the user clicks the OK button, text entered in the input field is returned. If the user clicks OK without entering any text, an empty string is returned. If the user clicks the Cancel button, this function returns?null.
lss94 提問者
點擊確定按鈕時,返回值是文本框的內(nèi)容,你什么都不輸入,那返回值是應(yīng)該就是空的咯?不過我還不太理解內(nèi)容為空與null的區(qū)別,有可能跟這個有關(guān)吧,我是這么想的(⊙o⊙)
我知道點取消返回null主要是想知道在我不輸入的情況下,返回值應(yīng)該也是null才對,怎么什么都不顯示?
我同意
prompt點取消返回的是null,你可以查下資料
舉報
本課程從如何插入JS代碼開始,帶您進入網(wǎng)頁動態(tài)交互世界
4 回答為什么用prompt輸入。不過輸入什么,都返回default
3 回答新增的節(jié)點不能輸入內(nèi)容;如何讓新增的行可以輸入內(nèi)容
2 回答如果輸入的內(nèi)容有一個不是數(shù)字時輸出為NaN如何解決
3 回答prompt與switch不能同時用嗎?
3 回答switch和prompt()語句結(jié)合怎么不顯示內(nèi)容
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-03-17
參考MDN:https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
When the user clicks the OK button, text entered in the input field is returned. If the user clicks OK without entering any text, an empty string is returned. If the user clicks the Cancel button, this function returns?null.
2016-03-17
點擊確定按鈕時,返回值是文本框的內(nèi)容,你什么都不輸入,那返回值是應(yīng)該就是空的咯?不過我還不太理解內(nèi)容為空與null的區(qū)別,有可能跟這個有關(guān)吧,我是這么想的(⊙o⊙)
2016-03-17
我知道點取消返回null主要是想知道在我不輸入的情況下,返回值應(yīng)該也是null才對,怎么什么都不顯示?
2016-03-17
我同意
2016-03-17
prompt點取消返回的是null,你可以查下資料