大佬們看看,我的if else語句怎么運(yùn)行不出來
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
? <script type="text/javascript">
?var lin = prompt("您有多少存款","500");
if(lin=500)
{alert(wa);}
else{
alert(ye);
}
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" />
</body>
</html>
2018-11-13
還有就是alert中的值未定義的時(shí)候要加引號(hào)
2018-11-13
一個(gè)'='是賦值 兩個(gè) == 才是等于
2018-11-11
這個(gè)才是可以運(yùn)行的代碼:
<!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 lin = prompt("您有多少存款","500");//500是默認(rèn)值
? if(lin>=500){
? alert("wa");
? }
? ? else{
? ? ? ? ?alert("ye");
? ? ? ? ?}
}
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" />
</body>
</html>
2018-10-23
沒有函數(shù)function??rec(){
}
2018-10-18
if是Boolean類型,簡(jiǎn)單來說就是判斷對(duì)錯(cuò),而“= ”是一個(gè)賦值,而不是比較值“==” 所以不會(huì)在做判斷,第二個(gè) 作為彈出框 alert();里面的東西是需要英文雙引號(hào),但如果有一個(gè)變量在前面被賦值帶上了雙引號(hào)可以直接放入alert中。
2018-10-09
你有兩個(gè)錯(cuò)誤,第一個(gè)? if(lin==500)不是=,是==。
第二個(gè)alert("wa");?和?alert("ye");括號(hào)里面要打雙引號(hào)
2018-10-09
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
? <script type="text/javascript">
? var lin = prompt("您有多少存款","500");
? if(lin==500){
? alert("wa");
? }
? ? ? ? ?else{
? ? ? ? ?alert("ye");
? ? ? ? ?}
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" />
</body>
</html>