2012年2月4日 星期六

jquery_setTimeout_clock(Jquery)

function clock(){
                var now,hours,minutes,seconds,time;
                now = new Date();
                hours = now.getHours();
                minutes = now.getMinutes();
                seconds = now.getSeconds();
                time = (hours >= 12) ? "a.m.":"p.m.";
                time += ((hours > 12) ? hours - 12 : hours) + " H";
                time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
                time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
                $("#gundamTime").html(time);
                setTimeout(clock,1000);
             }       

沒有留言:

張貼留言