Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  javascript  >  正文 js判断闰年(闰年计算方法)

js判断闰年(闰年计算方法)

发布时间:2015-07-16   编辑:www.jquerycn.cn
本文介绍了js 判断闰年的方法,js实现闰年计算的小例子,有需要的朋友参考下。

例子,js 判断闰年的实现代码。
 

复制代码 代码示例:
<html>
<head>
   <meta http-equiv="content-type" content="text/html;charset=gb2312">
   <title>判断闰年_www.jquerycn.cn</title>
   <script type="text/javascript" languge="javascript">
    //能被4整除且不能被100整除
    //或
    //能被100整除且能被400整除
    function isLeapYear(){
     var pYear=window.myForm.theYear.value;
     if(!isNaN(parseInt(pYear))){
      if((pYear%4==0 && pYear%100!=0)||(pYear%100==0 && pYear%400==0)){
       window.alert(pYear+"是闰年!");
      }else{
         window.alert(pYear+"不是闰年!");
      }
     }else{
      window.alert("请输入正确年份!");
     }
       }
   </script>
</head>
<body>
   <form action="#" name="myForm" method="post">
    <p>请输入要判断闰年的年份:<p/>
    <input name="theYear" type="text">
    <input name="select" type="button" value="计算" onClick="isLeapYear()">
   </form>
</body>
</html>

您可能感兴趣的文章:
php判断闰年的三种方法(闰年计算方法)
php判断闰年(闰年计算方法)
php判断是否为闰年
JavaScript判断是否闰年 闰年计算方法
PHP怎么判断一年是否为闰年?
php判断平年还是闰年
js判断闰年(闰年计算方法)
Js判断闰年与闰年计算方法示例
js判断某年某月有多少天(闰年计算方法)
calendar如何判断python3时间?

关键词: 闰年  闰年计算方法   
[关闭]