html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Documenttitle>
<style>
table {
width: 500px;
margin: auto;
border: 1px solid black;
border-collapse: collapse;
}
tr,
td {
height: 40px;
color: blue;
text-align: center;
border: 1px solid black;
}
style>
<body>
<h1 align='center'>判断出生年份是否为闰年h1>
<table>
<tr>
<td>学院:td>
<td>软件学院td>
tr>
<tr>
<td>姓名:td>
<td>黄楚td>
tr>
<tr>
<td>学号:td>
<td>211451082208td>
tr>
<tr>
<td>出生年份:td>
<td><select name="year" id="year" onchange='f()'>
<option value="1998">1998年option>
<option value="1999">1999年option>
<option value="2000">2000年option>
<option value="2001">2001年option>
<option value="2002">2002年option>
<option value="2003">2003年option>
<option value="2004">2004年option>
select>
td>
tr>
<tr>
<td>出生年份是否为闰年:td>
<td id='answer'>td>
tr>
table>
<script>
function isRunYear(year){
if(year%4==0&&year%100!=0){
return true;
}else{
return false;
}
}
function f(){
var y=document.getElementsById('year');
var i=y.selectedIndex;
var s=isRunYear(y[i].value);
if(s==true){
document.getElementById('answer').value=y[i].value+"是闰年";
}else{
document.getElementById('answer').value=y[i].value+"不是闰年";
}
}
script>
body>
html>
function f() {
var y = document.getElementById('year'); //重点
var i = y.selectedIndex;
var s = isRunYear(y[i].value);
if (s == true) {
document.getElementById('answer').innerText = y[i].value + "是闰年";
} else {
document.getElementById('answer').innerText = y[i].value + "不是闰年";
}
}