js实现倒计时+div下落
全部由js动态生成结点,body内无内容
- <style>
- #count{
- position: absolute;
- text-align: center;
- width: 240px;
- height: 260px;
- top: 230px;
- left: 750px;
- margin: 0;
- border: 10px black solid;
- border-radius: 240px;
- font-size: 200px;
- }
- .block{
- background: red;width: 50px;
- height: 50px;
- display: inline-block;
- margin-left: 15px;
- position: absolute;
- top: 20px;
- left: 0;
- }
- </style>
- <body></body>
- <script>
- var oBody=document.getElementsByTagName('body')[0];
- function countDown() {
- oBody.innerHTML='<div id="count">3</div>';
- var oDiv=document.getElementById('count');
- oDiv.timer=setInterval(function () {
- oDiv.innerText=parseInt(oDiv.innerText)-1;
- if (oDiv.innerText==0)
- {
- clearInterval(oDiv.timer);
- show(); //调用show()方法
- }
- },1000);
- }
- countDown();
- function show() { //动态生成n个小方块
- oBody.innerText='';
- for (var i=0;i<23;i++){
- oBody.innerHTML+="<div class='block' style='top: 20px;left:"+i*70+"px;'></div>"
- }
- var timer=null;
- var num=0;
- var aDiv=document.getElementsByTagName("div");
- timer=setInterval(function () {
- drop(aDiv[num]);
- num++;
- if (num===aDiv.length){
- clearInterval(timer);
- }
- },100);
- }
- function drop(obj) { //把当前小方块向下掉
- obj.timer=setInterval(function () {
- obj.style.top=parseInt(obj.style.top)+50+'px';
- if (parseInt(obj.style.top)>800){
- obj.style.top=800+'px';
- clearInterval(obj.timer);
- }
- },50);
- }
- </script>
js实现倒计时+div下落的更多相关文章
- 一个简单的js实现倒计时函数
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js时间倒计时
看了网上的其他的例子,觉得写的都有点复杂,不好理解,于是自己动手写了个. 本来想封装成jquery插件,但是觉得因为功能很简单,没有必要做成jquery插件,引用的时候不需要引入jqery库,这里直接 ...
- js实现倒计时及时间对象
JS实现倒计时效果代码如下: <!doctype html> <html> <head> <meta charset="utf-8"> ...
- JS实现倒计时(天数,时,分,秒)
<!DOCTYPE html> <html> <head> <meta charset="utf-8" > <titl ...
- 使用html+css+js实现倒计时,开启你痛苦的倒计时吧
使用html+css+js实现倒计时,开启你痛苦的倒计时吧 效果图: 这是我痛苦的倒计时,呜呜呜 好啦,再痛苦还是要分享代码,代码如下,复制即可使用: <!DOCTYPE html> &l ...
- js网页倒计时精确到秒级
网页实时倒计时,精确到秒级,和天数倒计时原理一样. 一个很好用的js倒计时!网页实时倒计时,精确到秒级,和天数倒计时原理一样.js倒计时一般用于商城网站团购,特卖,很多地方都可用到!希望能够给大家带来 ...
- 用JS实现倒计时(日期字符串作为参数)
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- JS实现倒计时效果,并退出系统
背景:由于单点登录后,一直在本系统操作,可是门户体统的会话失效时间有30分钟,所以30分钟后,需要重新登录系统才可以进行操作. 方法:想过在本系统中的每个操作都先跟门户系统进行交互,渠道refresh ...
- 倒计时的js实现 倒计时 js Jquery
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=987 一.如火如荼的团 ...
随机推荐
- 2019-1-5-Windows-的-Pen-协议
title author date CreateTime categories Windows 的 Pen 协议 lindexi 2019-01-05 11:14:49 +0800 2019-01-0 ...
- quotastats - 显示与配额子系统相关的统计信息
SYNOPSIS(总览) quotastats DESCRIPTION(描述) 该命令显示与配额子系统相关的统计信息.
- python常用函数 N
nlargest(int , iterable,key) 查找最大的n个元素. 例子: 还支持传入key进行复杂元素比较:如:nlargest (n, list,key=lambda a:a[b]). ...
- bzoj2004 [Hnoi2010]Bus 公交线路 矩阵快速幂+状压DP
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2004 题解 如果 \(N\) 没有那么大,考虑把每一位分配给每一辆车. 假设已经分配到了第 \ ...
- Codeforces Round #584 - Dasha Code Championship - Elimination Round (rated, open for everyone, Div. 1 + Div. 2)
怎么老是垫底啊. 不高兴. 似乎 A 掉一道题总比别人慢一些. A. Paint the Numbers 贪心,从小到大枚举,如果没有被涂色,就新增一个颜色把自己和倍数都涂上. #include< ...
- Yii Ar model 查询
Ar model 查询 参照表: CREATE TABLE tbl_user ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, username VA ...
- 刷题or源码链接
Hadoop权威指南的Github https://github.com/tomwhite/hadoop-book hadoopAPI http://hadoop.apache.org/docs/cu ...
- sql语句中判断空值的函数
COALESCE()函数 主流数据库系统都支持COALESCE()函数,这个函数主要用来进行空值处理,其参数格式如下: COALESCE ( expression,value1,value2……,v ...
- 【leetcode】1018. Binary Prefix Divisible By 5
题目如下: Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted a ...
- MongoDB笔记【2】——基本概念和基本指令
- 基本概念 数据库(database) 集合(collection) 文档(document) - 在MongoDB中,数据库和集合都不需要手动创建,当我们创建文档时,如果文档所在的集合或数据库不存 ...