這是一個(gè)數(shù)字比較問(wèn)題
<!DOCTYPE??HTML> <html?> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>函數(shù)</title> <script?type="text/javascript"> //定義函數(shù) function?age(x,y); { ????var?x?=?parseInt(prompt("請(qǐng)輸入第一個(gè)數(shù):")); ????var?y?=?parseInt(prompt("請(qǐng)輸入第二個(gè)數(shù):")); ???? ????if?(x?<?y) ????{ ????????document.write(x?"<"?y); ????} ????else?if?(x?>?y) ????{ ????????document.write(x?">?"?y); ????} ????else ????{ ????????document.write(x?"="?y); ????} } //函數(shù)體,判斷兩個(gè)整數(shù)比較的三種情況 ? //調(diào)用函數(shù),實(shí)現(xiàn)下面兩組數(shù)中,返回較大值。 ??//document.write("?5?和?4?的較大值是:"+"<br>"); ??//document.write("?6?和?3?的較大值是:"?);? </script> </head> <body> <input?type?="button",value?=?"點(diǎn)擊",onclick="age()"> </body> </html>
請(qǐng)問(wèn)各位,我的代碼問(wèn)題出現(xiàn)在什么地方?為什么不能執(zhí)行下去
2016-11-29
我只能說(shuō)樓主各種粗心,你搞開(kāi)發(fā)的時(shí)候要是這樣來(lái),你一天的時(shí)間都在找BUG了
2016-11-29
我把你的程序稍改一下就可以了:
1、<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>改成<meta?http-equiv="Content-Type"?content="text/html“ ? charset=“utf-8” />
2、function?age(x,y); ? 去掉分號(hào) ? ?function?age(x,y)
3、document.write(x?"<"?y);括號(hào)里面加“+”,改成document.write(x +"<" +y);
? ? ?document.write(x?">?"?y);與document.write(x?"="?y);也是同樣的道理。
4、<input?type?="button",value?=?"點(diǎn)擊",onclick="age()">用空格隔開(kāi),不要用逗號(hào),改成
? ??<input?type?="button" ? value?=?"點(diǎn)擊" ? onclick="age()">
不知道我這樣說(shuō)你懂了沒(méi),你有些低級(jí)錯(cuò)誤,寫(xiě)程序時(shí)應(yīng)該注意點(diǎn)