2.打开eclipse之后, 新建一个类,输入类名之后,点击“Finish”
3.点击“Finish”之后,写好注释
<!DOCTYPE html><html lang="en">
<head>
<title>奇偶数</title>
</head>
<body>
<input type=text>
<input type=button value="判断" onclick="chk(value)">
<p id="demo"></p>
<script>
function chk(num) {
var inputs = document.getElementsByTagName('input')[0]
var value = inputs.value
num = value
console.log(num)
alert((num % 2 == 0) ? "偶数" : "奇数") //判断是否能整除2
}
</script>
</body>
</html>
function jishu(num){
console.log('我是奇数:'+num)
}
function oushu(num)
{
console.log('我是偶数:'+num)
}
for(var i=1i<=100i++)
{
if(i%2==0)
{
oushu(i)
}
else
{
jishu(i)
}
}