嘿傢伙我有這個代碼,但我不知道我做錯了什麼。一旦我輸入我的號碼到文本框中,我點擊計算什麼也沒有發生。即使功能Javascript
<html>
<head>
<title>Week 3 - Exercise 3-3</title>
<script type="text/javascript">
function evenTest(num1) { //function receives one parameter
var num=num1; //create and assign variable to number passed
(num % 2==0) ? akert("Number is even"):alert("Number is odd");
if (num>20) {
alert("Number is > 20");
}
else {
alert("Number is not greater than 20");
//message if <=20
} //end else
} //end function
</script>
</head>
<body>
<h1>Exerise 3-3 - Even Function</h1>
<form name="form1">
Enter a number:<input name="firstNum" type="text"/><br/>
<input type="button" value ="Calculate" onclick=evenTest(form1.firstNum.value)/>
</form>
</body>
有很多的代碼去錯了,任何人都回答之前,你看到的任何開發工具控制檯錯誤? –
你的代碼包含一個明顯的語法錯誤 –
你有一個拼寫錯誤:'akert'而不是'alert'。請使用一些瀏覽器開發工具(在瀏覽器中按F12),並在發佈問題前檢查此類錯誤。 –