我的代碼有問(wèn)題嗎?為什么點(diǎn)了按鈕沒(méi)反應(yīng)
<!DOCTYPE html>
<html>
<head>
?? ?<meta charset="UTF-8">
?? ?<title>知識(shí)點(diǎn)</title>
?? ?<script type="text/javascript">
???? function rec () {
?? ??? ?var score;
?? ??? ?score=prompt("請(qǐng)輸入您的期末考試成績(jī):");
?? ??? ?if (score>=90)
?? ??? ?{
?? ??? ??? ?document.write("你很棒");
?? ??? ?}
?? ??? ?else if (score>=80)
?? ??? ?{
?? ??? ??? ?document.write("嗯,還行吧");
?? ??? ?}
?? ??? ?else if (score>=70)
?? ??? ?{
?? ??? ??? ?document.write("要努力了哦");
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?document.write("小子,愛(ài)情不能當(dāng)飯吃");
?? ??? ?};
?? ?};
</script>
</head>
<body>
<input name="button" type="button" onclick="hanshu()" value="函數(shù)與函數(shù)調(diào)用" />
</body>
</html>
2015-07-02
這里2個(gè)分號(hào)是什么情況,刪掉。還有最后的}請(qǐng)改為英文狀態(tài)下的}
上面定義的函數(shù)是rec(),這里調(diào)用的函數(shù)怎么成了hanshu(),改過(guò)來(lái)就好了
修改后的全代碼
2015-07-06
請(qǐng)問(wèn),
? ?};
};
這種情況是這樣的,我在上面還有別的函數(shù),如果不用分號(hào),會(huì)不會(huì)不起作用?我上代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>知識(shí)點(diǎn)</title>
<script type="text/javascript">
function tangchu () {
var mymessage=confirm("關(guān)于alert彈出框的知識(shí)你了解了嗎?");
if (mymessage==true)
{?
alert("alert是警告彈出框,格式為:aletr(顯示內(nèi)容)");
}
else
{?
alert("格式不對(duì),不會(huì)顯示");
}
};
function shuchu () {
var mymessage=confirm("輸出內(nèi)容命令知道怎么用嗎?");
if (mymessage==true)
{?
document.write("知道,格式為:document.write(輸出內(nèi)容)");
}
else
{?
document.write("不知道,格式錯(cuò)誤不顯示效果!");
}
};
function queren () {
var mymessage=confirm("學(xué)會(huì)用confirm確認(rèn)對(duì)話框了沒(méi)有?");
if (mymessage==true)
{?
document.write("confirm是確認(rèn)對(duì)話框,通過(guò)IF...ELSE...關(guān)系返回布爾值,如果消息返回為真,則執(zhí)行下面的代碼;否則執(zhí)行ELSE下面的代碼");
}
else
{?
document.write("切記,在IF函數(shù)與ELSE之間的花括號(hào)那里把默認(rèn)加上的分號(hào)去掉,否則,不執(zhí)行");
};
};
function panduan () {
var mymessage=confirm("你會(huì)用IF條件判斷語(yǔ)句嗎?");
if (mymessage==true)
{?
document.write("IF(括號(hào)里的是條件表達(dá)式,一般是用邏輯運(yùn)算符來(lái)表達(dá)兩邊的關(guān)系),比如(>=或<=或==)大于等于/小于/等于等于,右邊為true如果條件成立,則執(zhí)行IF下面的代碼;如果條件不成立,則執(zhí)行else下面的代碼");
}
else
{?
document.write("IF條件不成立,則執(zhí)行此代碼");
};
};
function hanshu () {
var mymessage=confirm("學(xué)過(guò)函數(shù)嗎,函數(shù)調(diào)用會(huì)嗎");
if (mymessage==true)
{?
document.write("函數(shù)格式:FUNCTION 函數(shù)名(){這里寫(xiě)函數(shù)內(nèi)容,主要是一些重復(fù)的表達(dá)式}一個(gè)函數(shù)結(jié)束可以打上分號(hào),分號(hào)就是代表結(jié)束。");
}
else
{?
document.write("否則不顯示;一定要先給變量賦值;賦值的內(nèi)容是需要展示的效果");
}
};
function tiwen () {
var socore;
socore=prompt("請(qǐng)輸入您的期末考試成績(jī):");
if (socore>=90)
{?
document.write("你很棒!");
}
else if (socore>=80)//多重語(yǔ)句多用于不同值之間的比較
{?
document.write("嗯,還行!");
}
else if (socore>=70)//嵌套判斷語(yǔ)句,if..(else if..)else..
{?
document.write("要加油了!");
}
else if (socore>=60)
{?
document.write("你太次了!");
}
else
{?
document.write("你要努力了");
};
};
function beifen () {
var chenhu;
chenhu=prompt("只要你回答對(duì)這個(gè)問(wèn)題,大大地有獎(jiǎng):");
if (chenhu=="爸爸")//IF括里號(hào)如果是等于,一定要是==才可以,切記!
{?
alert("好,乖兒子!你回答對(duì)了!");
}
else
{?
document.write("你個(gè)笨豬,連這個(gè)都不知道!");
}
}
</script>
</head>
<body>
<input name="button" type="button" onclick="tangchu()" value="彈出框" />
<input name="button" type="button" onclick="shuchu()" value="輸出內(nèi)容" />
<input name="button" type="button" onclick="queren()" value="確認(rèn)對(duì)話框" />
<input name="button" type="button" onclick="panduan()" value="判斷語(yǔ)句IF" />
<input name="button" type="button" onclick="hanshu()" value="函數(shù)與函數(shù)調(diào)用" />
<input name="button" type="button" onclick="tiwen()" value="提問(wèn)式彈出框" />
</body>
</html>
好幾個(gè)函數(shù)放在同一個(gè)頁(yè)面下,我剛才的那樣做是為了防止不返回值,是不是在寫(xiě)法有錯(cuò)誤?
謝謝