JS simulation on-time online snapping effect _ date

Source: Internet
Author: User
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> snapping time countdown effect </title> <script language=" JavaScript "> function $ (Element) { return document.getElementById (Element); ()//limited-snapped var the_s=new Array (); function View_time (The_s_index,objid) {if (the_s[the_s_index]>=0) {var the_d=math.floor (the_s[the_s_index]/3600 )/24 var the_h=math.floor ((the_s[the_s_index]-the_d*24*3600)/3600); var The_m=math.floor ((the_s[the_s_index]-the_d*24*3600-the_h*3600)/60); var the_s= (the_s[the_s_index]-the_h*3600)%60; html = "still left"; if (the_d!=0) HTML + = the_d+ "Days"; if (the_d!=0 | | the_h!=0) HTML = ' <span class= ' hour ' > ' + (the_h+ (the_d*24)) + "</span> hour"; if (the_d!=0 | | the_h!=0 | | the_m!=0) HTML = ' <span class= ' minute ' > ' +the_m+ ' </span> minute "; html + + ' <span class= ' second ' > ' +the_s+ ' </span> sec; $ (objid). InnerHTML = html; the_s[the_s_index]--; }else{$ (objid). InnerHTML = "closed"; } </script> </pead> <body> <p class= "Time" id= "xsq_2402" > has <span class= "Hour" >14&l T;/span> hours <span class= "Minute" >49</span> min <span class= "Second" >44</span> sec </p> <script language= "JavaScript" > var startdate= new Date ("2010/07/16 09:07:43"); var enddate= new Date ("2010/07/17 00:00:00"); The_s[2402]= (Enddate.gettime ()-startdate.gettime ())/1000; SetInterval ("View_time (2402, ' xsq_2402 ')", 1000); </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.