_javascript technique of digital clock instance with JavaScript realizing scrolling effect

Source: Internet
Author: User

There are many examples of how JavaScript can realize digital clock effect on the Internet, but this article introduces the digital clock of scrolling effect. Small series think the effect is very dazzle, share below to everybody.

Let's take a look at the cool effect.

The following is a code instance

JavaScript code section:

Window.onload=function () {
function Todou (n) {return
n<10? 0 "+n:" "+n"
;
var oimg=document.getelementsbytagname ("img");
SetInterval (clock,1000);
Clock ()
function Clock () {
var odate=new Date ();
var oh=odate.gethours ();
var of=odate.getminutes ();
var om=odate.getseconds ();
var Str=todou (OH) +todou (OF) +todou (OM);
for (Var i=0;i<oimg.length;i++) {Move
(oimg[i],{"margintop": -35*str.charat (i)});}}

DIV+CSS Layout section:

<ul>
<li></li>
<li> </li>
<li>:</li>
<li> </li> <li></li>
<li>:</li>
<li></li>
<li> </li>
</ul>
*{padding:0; margin:0; list-style:none;}
ul{width:200px; margin:100px Auto;
li{float:left; height:35px; overflow:hidden; line-height:35px;}

Summarize

The above is about using JavaScript to achieve scrolling effect of the digital clock All instance code, the code is very simple but the effect is very good, hope to help you need.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.