<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0 auto;
}

#kaishi {
text-align: center;
background-color: red;
width: 300px;
height: 100px;
border: 1px solid black;
}
</style>
</head>

<body>
<div id="kaishi">
距离2017年还有
<br />
<input type="text" id="daojishi" / style="text-align: center;">
<script>
window.onload=function(){

setInterval(function() {

var time = new Date();
var year = time.getFullYear();
var month = time.getMonth() + 1;
var day = time.getDate();
var hours = time.getHours();
var minutes = time.getMinutes();
var secomds = time.getSeconds();
tian = 0;
if(month == 8 || month == 10 || month == 12) {
tian = 31;
} else if(month == 9 || month == 11) {
tian = 30;
}
document.getElementById("daojishi").value = (2017 - year - 1) + "年" + (12 - month - 1) + "月" + (tian - day - 1) + "日" + (24 - hours - 1) + "时" + (60 - minutes - 1) + "分" + (60 - secomds - 1) + "秒";
}, 1000);
}
</script>
</div>
</body>

</html>

javascript平时小例子④(setInterval使用2)的更多相关文章

  1. javascript平时小例子③(setInterval使用1)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  2. javascript平时小例子⑨(小型抽奖功能)

    <!doctype html><html lang="en"> <head> <meta charset="utf-8" ...

  3. javascript平时小例子①(移动的小div)

    css样式: #box{ width: 300px; height: 300px; background: deepskyblue; position: absolute; margin-right: ...

  4. javascript平时小例子⑧(导航置顶效果)

    <!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...

  5. javascript平时小例子⑦(鼠标跟随的div)

    <!doctype html><html> <head> <meta charset="utf-8"> <title>无 ...

  6. javascript平时小例子⑥(简易计算器的制作)

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  7. javascript平时小例子⑤(投票效果的练习)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  8. javascript平时小例子②(正则表达式验证邮箱)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>邮 ...

  9. JavaScript—面向对象小例子

    什么是面向对象 要是以前别人问我.随口道来,封装继承多态,万物皆对象...一大推.说的自己都以为自己掌握了面向对象.呵呵一笑.确实掌握了 只是不会用..... 什么是面向对象编程 以前 学.Net 虽 ...

随机推荐

  1. Struts2基本配置详解

    Struts2配置文件加载顺序 struts2 配置文件由核心控制器加载 StrutsPrepareAndExecuteFilter (预处理,执行过滤) init_DefaultProperties ...

  2. js Array对象

    http://www.w3cschool.cc/js/js-obj-array.html 创建新方法 原型是JavaScript全局构造函数.它可以构建新Javascript对象的属性和方法. 实例: ...

  3. 《DSP using MATLAB》示例Example5.6

    代码: x = [1, 1, 1, 1]; N = 4; X_DFT = dft(x,N); % DFT of x(n) magX_DFT = abs(X_DFT), phaX_DFT = angle ...

  4. LaunchCharacter

    /** Set a pending launch velocity on the Character. This velocity will be processed on the next Char ...

  5. oracle通过sequence定义触发器支持id的自增

    sequence:s_author_id,从1开始步幅是1,最大值是999999999 -- Create sequence create sequence S_AUTHOR_ID minvalue ...

  6. html5大纲

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

  7. Shell 编程基础之 Case 练习

    一.语法 case $变量 in "第一个变量内容") # 每个变量内容建议用双引号括起来,关键字则为小括号 ) # 执行内容 ;; # 每个类别结尾使用两个连续的分号来处理! & ...

  8. 熟悉熟悉常用的几个算法用JS的实现

    (1)数组去重 原理:定义一个对象obj,然后把数组元素作为obj的属性名,利用属性名是否重复进行判重 1 var unique = function(arr){ 2 let obj = {}; 3 ...

  9. Codeforces Round #353 (Div. 2) A. Infinite Sequence

    Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its fi ...

  10. mysql数据向Redis快速导入

    Redis协议 *<args><cr><lf> 参数个数 $<len><cr><lf> 第一个参数长度 <arg0> ...