当前位置:首页 > 网页特效 > 时间日期 >

jquery 模拟出的LCD 时钟效果

时间:2014-06-09 08:28 来源:互联网 作者:源码搜藏 收藏 推荐

运行代码 保存代码 复制代码 提示:您可以先修改部分代码再运行,保存代码功能在Firefox下无效。
  • jquery 模拟出的LCD 时钟效果,如果页面有错误,请刷新一次就正常了。
  • <script type="text/javascript">
    $(document).ready(function(){
    jQuery.fn.LCDClock = function(options){
    var $clock = $(this);
    var defaultOptions = {
    timeText : $clock.text(),
    };
    if ($clock.text()!=""){
    defaultOptions = {timeText : $clock.text()}
    }
    options = $.extend(defaultOptions,options);
    if (typeof(options.timeText)=="undefined" || options.timeText==""){
    $clock.text("启动LCD Clock失败!")
    }
    else{
    window.setTimeout(
    function(){
    var time = new Date(options.timeText);
    time.setSeconds( time.getSeconds() + 1 );
    var year = time.getFullYear();
    var month = time.getMonth() + 1;
    var day = time.getDate();
    var hour = time.getHours();
    var minute = time.getMinutes();
    var second = time.getSeconds();
    var time2 = year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second;
    options.timeText = time2;
    var html = "";
    var Y1 = Math.floor(year/1000);
    var Y2 = Math.floor((year-1000*Y1)/100);
    var Y3 = Math.floor((year-1000*Y1-100*Y2)/10);
    var Y4 = year%10;
    html += "<span class=\"LCDclock\">";
    html += "<span class=\"num" + Y1 + "\"></span><span class=\"num" + Y2 + "\"></span><span class=\"num" + Y3 + "\"></span><span class=\"num" + Y4 + "\"></span><span class=\"year\"></span>";
    html += "<span class=\"num" + Math.floor(month/10) + "\"></span><span class=\"num" + month%10 + "\"></span><span class=\"month\"></span>";
    html += "<span class=\"num" + Math.floor(day/10) + "\"></span><span class=\"num" + day%10 + "\"></span><span class=\"day\"></span>";
    html += "<span class=\"num" + Math.floor(hour/10) + "\"></span><span class=\"num" + hour%10 + "\"></span><span class=\"numseparator\"></span>";
    html += "<span class=\"num" + Math.floor(minute/10) + "\"></span><span class=\"num" + minute%10 + "\"></span><span class=\"numseparator\"></span>";
    html += "<span class=\"num" + Math.floor(second/10) + "\"></span><span class=\"num" + second%10 + "\"></span>";
    html += "</span>";
    $clock.html(html);
    $clock.LCDClock(options);
    },
    1000
    );
    }
    }
    $("#time4").text(Date());
    $("#time1").LCDClock();
    $("#time2").LCDClock();
    $("#time3").LCDClock();
    $("#time4").LCDClock();
    });
    </script>
由源码搜藏网整理,转载请注明出处https://www.codesocang.com/tx-shijian/8635.html
下一篇:没有了

时间日期下载排行

最新文章