网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 使用jQuery方法获取当前日期和时间
内容
    代码如下:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>当期时间 = www.update8.com</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <style type="text/css">
    .date{height:100px;line-height:100px;margin:0 auto;font-family:Arial, Helvetica, sans-serif;font-size:40px;
    border:solid 1px #ccc;box-shadow:0 0 3px rgba(0,0,0,0.3) inset;border-radius:5px;text-shadow:1px 1px 2px rgba(0,0,0,0.3);}
    .date strong{padding:0 10px;display:inline-block;height:100px;border-right:solid 1px #ccc;}
    </style>
    </head>
    <body>
    <h1>js简单的获取当前日期和时间</h1>
    <p>
    <strong id="Y"></strong>
    <strong id="MH"></strong>
    <strong id="TD"></strong>
    <strong id="D"></strong>
    <strong id="H"></strong>
    <strong id="M"></strong>
    <strong id="S"></strong>
    </p>
    <script type="text/javascript">
    $(document).ready(function(){
    setInterval(showTime, 1000);
    function timer(obj,txt){
    obj.text(txt);
    }
    function showTime(){
    var today = new Date();
    var weekday=new Array(7)
    weekday[0]="星期一"
    weekday[1]="星期二"
    weekday[2]="星期三"
    weekday[3]="星期四"
    weekday[4]="星期五"
    weekday[5]="星期六"
    weekday[6]="星期日"
    var y=today.getFullYear()+"年";
    var month=today.getMonth()+"月";
    var td=today.getDate()+"日";
    var d=weekday[today.getDay()];
    var h=today.getHours();
    var m=today.getMinutes();
    var s=today.getSeconds();
    timer($("#Y"),y);
    timer($("#MH"),month);
    timer($("#TD"),td);
    timer($("#D"),d);
    timer($("#H"),h);
    timer($("#M"),m);
    timer($("#S"),s);
    }
    })
    </script>
    </body>
    </html>
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/18 8:23:08