闰年条件:能被4整除却不能被100整除的年份。世纪年份能被400整除的是闰年.
<body>
<span>请输入年份:</span><input type="text" id="nianfen" /><br />
<button id="tijiao">计算</button>
<script type="text/javascript">
var nianfenVal = document.getElementById("nianfen");
var tijiaoVal = document.getElementById("tijiao");
tijiaoVal.onclick = function(){
var nianfenValZ = parseInt(nianfenVal.value);
if (nianfenValZ%4 == 0 && nianfenValZ0 != 0 || nianfenValZ@0 == 0) {
alert("闰年");
} else{
alert("不是闰年");
}
};
</script>
</body>
转载请注明原文地址: https://ju.6miu.com/read-40397.html