代码贯穿全程,高度融合实战
郑州达内IT培训
发表于:2021-04-14 09:43:48JavaScript基础 — 无限运动
var oBtn = document.getElementsByTagName('input')[0];
var timer=null;
var oBall = document.getElementById('ball');
var arr = [{left:100,top:100},{left:800,top:200},{left:400,top:600}];
var n = 0;
oBtn.onclick=function(){next();};
function next(){
timer=setInterval(function(){
move(oBall,{left:arr[n%arr.length].left,top:arr[n%arr.length].top},{complete:function(){next();}})n++;},300);}
JavaScript基础 — 文本时钟
function toDou(n) {
return n < 10 ? '0' + n : '' + n;
}
window.onload = function() {
var oDiv = document.getElementById('div1');
function clock(){
var oDate = new Date();
var iH = oDate.getHours();
var iM = oDate.getMinutes();
var iS = oDate.getSeconds();
oDiv.innerHTML = toDou(iH) + ':' + toDou(iM) + ':'+ toDou(iS);
}
clock();
setInterval(clock,1000);
JavaScript基础 — 简易秒表
function toDou(n) {
return n < 10 ? '0' + n : '' + n;
} window.onload = function() { var oT = document.getElementById('t1'); var oBtn = document.getElementById('btn1'); var oBtn2 = document.getElementById('btn2'); var timer = null; var num = parseInt(oT.value); var bSin = false; oBtn.onclick = function() { if (bSin) { return; } bSin = true; clearInterval(timer); function m(){ num++; var iM = parseInt(num / 60); var iS = num % 60; oT.value = toDou(iM) + ':' + toDou(iS); } m(); timer = setInterval(m,1000); }; oBtn2.onclick = function() { clearInterval(timer); bSin = false; }; };
代码贯穿全程,高度融合实战 原创内容,请点击郑州IT认证培训
热门课程
-
郑州Linux培训
询价
-
郑州php开发培训
询价
-
郑州unity3d课程培训
询价