請問一下,為什么無法跳出提示框的內(nèi)容?
請問一下,為什么無法跳出提示框的內(nèi)容?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全帶,準(zhǔn)備啟航</title>
<script src="script.js"></script>
<!--引入外部文件的方式-->
<script type="text/javascript">
//多行注釋
/* ?我是多行注釋!
? 我需要隱藏,
? 否則會報錯哦!*/
//在頁面中顯示文字
document.write("系好安全帶,準(zhǔn)備起航--目標(biāo)JS")
//頁面中彈出提示框
//單行注釋
? ?//我是單行注釋,我也要隱藏起來!
</script>
</head>
<body>
<input type="button" onClick="duihua()" value="系好安全帶,準(zhǔn)備啟航--目標(biāo)JS">
</body>
</html>
?function duihua(){?
?? ?var message=confirm("準(zhǔn)備好了嗎?");?
?? ? ? ?if(message===true) ??
? ? ?{alert("準(zhǔn)備好了,起航吧!"); ? ? ??
?????else{alert("你還需要多加努力!"); ? ?}?
?}?
script.js 中第 1、5 行報錯,unmatched { ,怎么會不匹配括號呢?
2016-01-12
?if(message==true) ? //這里是兩個等號
? ? ?{alert("準(zhǔn)備好了,起航吧!"); ?}//這里少了一個括號
2016-01-12
?function duihua(){?
?? ?var message=confirm("準(zhǔn)備好了嗎?");?
?? ? ? ?if(message===true) ??
? ? ?{alert("準(zhǔn)備好了,起航吧!"); ? ? ? ? ? ?//這里缺少}
?????else{alert("你還需要多加努力!"); ? ?}?
?}?
2016-01-12
<script type="text/javascript">
function duihua(){?
?? ?var message=confirm("準(zhǔn)備好了嗎?");?
?? ? ? ?if(message==true) ? //邏輯判斷兩個=
? ? ?{alert("準(zhǔn)備好了,起航吧!"); ? ? ? }//花括號少了一邊
?????else{alert("你還需要多加努力!"); ? ?}?
?}?
</script>