日期和时间特效-查看"今天是否为节假日"

————————————————

<script type="text/javascript">        
            function start(){                
                setInterval(function(){
                    var now = new Date();
                    var m = now.getMonth() + 1;
                    var d = now.getDate();
                    var str = '';
                    str += now.getYear() + 1900 + '年';
                    str += now.getMonth() + 1 + '月';
                    str += now.getDate() + '日';
                    str += now.getHours() + '时';
                    str += now.getMinutes() + '分';
                    str += now.getSeconds() + '秒';                    
                    if(now.getDay() >= 5){
                        str += ',今天是周末';
                    }else if(m==1 && d==1)
                        str += ',今天是周末';
                    else if(m==5 && d==1)
                        str += ',今天是劳动节';
                    else if(m==10 && d==1)
                        str += ',今天是国庆节';
                    else
                        str += ',今天不是节假日';
                    document.getElementById('left').innerHTML = str;
                },1000);
            }
        </script>

————————————————————————

<body style="text-align:center">
        <p>            
            <input type="button" value="查看今天是否节假日" onclick="start();"/>
        </p>
        <h2 id="left"></h2>        
    </body>

————————————————————————

posted @ 2016-09-29 11:14  承载梦想-韩旭明  阅读(420)  评论(0编辑  收藏  举报