Front-end development self-study javascript--show Current time

Source: Internet
Author: User

123<title>JavaScript</title>4<script language= "JavaScript" >5 functionShowtime () {6     varNow_time =NewDate ();//Create a Time object7     varHours = Now_time.gethours ();//To get the current number of hours8     varminutes = Now_time.getminutes ();//get the current number of minutes9     varseconds = Now_time.getseconds ();//gets the current number of secondsTen     varTimer = "" + ((Hours > 12)? Hours-12:hours);//assigning an hour value to a variable timer OneTimer + = ((minutes < 10)? ": 0": ":") + minutes;//assigning a minute value to a variable timer ATimer + = ((seconds < 10)? ": 0": ":") + seconds;//Assigning a second value to a variable timer -Timer + = "" + ((Hours > 12)? " PM ":" AM ");//Assign the character am or PM to a variable timer -Document.clock.show.value = timer;//output variable timer value in a form named Clock theSetTimeout ("Showtime ()", 1000);//set the Showtime () function to be called automatically once every second - } -</script> - +<body onload=showtime () > -<form name= "Clock" onsubmit= "0" > +<input type= "text" Name= "show" size= "Ten" style= "BACKGROUND-COLOR:LIGHTYELLO;BORDER-WIDTH:3;" > A</form> at</body> -

JavaScript is also good to play Ah!

The above for the first JS applet implementation display the current time!

Front-end development self-study javascript--show Current time

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.