html代码如下:
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><script>var year = prompt("请输入年份", "");if (year % 4 == 0 && year % 100 != 0|| year % 100 == 0 && year % 400 == 0) {document.write("闰年");}else{document.write("平年");}</script></body>
</html>
效果展示:
输入年份,显示闰年还是平年