<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>显示当前时间</title>
<script type="text/javascript">
function showtime(){//创建函数
   var now_time = new Date();//创建时间对象的实例
   var hours = now_time.getHours();//获得当前小时数
   var minutes = now_time.getMinutes();//获得当前分钟数
   var seconds = now_time.getSeconds();//获得当前秒数
   var timer = ""+ ((hours>12)?hours -12:hours);//将小时数值赋予变量timer
   timer+=((minutes<10)?":0":":")+minutes;//将分钟数赋予变量timer
   timer+=((seconds<10)?":0":":")+seconds;//将秒数赋予timer
   timer+=""+((hours>12)?" PM":" AM");//将字符AM或PM赋予变量timer
   document.clock.show.value=timer;//在名为clock的表单中输出变量timer的值
   setTimeout("showtime()",1000);//设置每隔一秒钟自动调用一次showtime()函数
}
</script>
</head>
<body onload="showtime()" >
<form name="clock" onsubmit="0">
<input type="text" name="show" size="10"
style=" border-width: 3;">
</form>
</script>
</body>
</html>

JavaScript 时间特效 显示当前时间的更多相关文章

  1. javascript 实现页面显示当前时间 动态读秒

    用户进入网站后,出于友好目的,可以添加一些欢迎语句,并且显示系统当前时间,动态读秒的操作.还是直接粘贴代码吧 <script type="text/javascript"&g ...

  2. javascript显示年月日时间代码显示电脑时间

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. Javascript 客户端实时显示服务器时间

    <!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...

  4. 前端开发自学之JavaScript——显示当前时间

    <html> <head> <title>JavaScript</title> <script language="javascript ...

  5. 【温故而知新-Javascript】时间效果(显示当前时间、显示当前日期、显示页面停留时间、倒计时)

    1.显示当前时间 <body onload="showtime()"> <div>当前时间: <span id="clock"&g ...

  6. javascript 以“年-月-日 时:分:秒”格式显示当前时间

    运行代码 /** * Created by shgbit on 2015/1/9. *js代码 */ function showNow(){ var t=new Date();    var mont ...

  7. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  8. JavaScript实时显示当前时间的例子

    用javascript代码在当前页面中实时显示当前时间.代码如下: <html> <head> <title>JavaScript 实时显示当前时间-www.jbx ...

  9. JavaScript显示当前时间的操作

    JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型.它的解释器被称为JavaScript引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在HTML(标 ...

随机推荐

  1. php 使用 restler 框架构建 restfull api

    php 使用 restler 框架构建 restfull api restler 轻量级,小巧,构建restfull api非常方便! 官网:http://restler3.luracast.com/ ...

  2. centos7 安装mariaDB 以及 phpmyadmin的安装

    centos7 安装mariaDB 以及 phpmyadmin的安装 一:安装mariadb, mariadb 是 mysql 的一个分支,基本和mysql一样的 1. yum -y install ...

  3. java main函数

    public static void main(String[] args)[String args[]]也对 1)public :公共的权限最大,在任何情况下都可以访问. 原因:为了保证java虚拟 ...

  4. @font-face字体文件用法

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  5. font-face字体文件引入方式

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  6. Python 练习 21

    #!/usr/bin/python # -*- coding: UTF-8 -*- h = 0 leap = 1 from math import sqrt from sys import stdou ...

  7. python 练习 13

    #!/usr/bin/python # -*- coding: UTF-8 -*- l = [] for i in range(3): x = int(raw_input('integer:\n')) ...

  8. [maven] 常用仓库地址

    共有的仓库 http://mvnrepository.com/ http://repo1.maven.org/maven2/ http://repository.jboss.com/maven2/ h ...

  9. 1029c语言文法2理解

    program → external_declaration | program external_declaration <程序>→ <外部声明>|<程序>< ...

  10. 补交git、ssh

    本来应该早就应该交的,自己给忘记了,非常抱歉,现在补交上来 词频统计: 代码地址:https://coding.net/u/liuff/p/cipin/git ssh:git@git.coding.n ...