判断是否是闰年源码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>

<body>
<script language="JavaScript" type="text/javascript">
<!--
//由用户输入要判断的年份
var year=prompt("请输入要判断是否为闰年的年份:",2000);
year
=parseInt(year);                //可选:将year转换为数字类型
var check4=(0==year%4);            //判断年份是否能被4整除
var check100=(0==year%100);        //判断年份是否能被100整除
var check400=(0==year%400);        //判断年份是否能被400整除
//
给出判断结果
if((check4 && !check100) || check400)alert(year+"年是闰年。");
else alert(year+"年不是闰年。");

//-->
</script>

</body>
</html>


用javascript 中的prompt用户输入框来让用户输入年份进行判断。

相关文章:

  • 2021-11-28
  • 2021-04-09
  • 2021-12-04
  • 2022-02-01
  • 2021-11-28
  • 2021-10-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-06-24
  • 2021-11-28
  • 2021-11-28
相关资源
相似解决方案