JS无聊之作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
var handleUp;
var handleDown;
function changeUp()
{
var div= document.getElementById('div1');
if(parseInt(div.style.height)<=200)
{
div.style.height=(parseInt(div.style.height)+8).toString()+'px';
div.style.width=(parseInt(div.style.width)+8).toString()+'px';
}
else if(parseInt(div.style.height)>200)
{
clearInterval(handleUp);
showDown();
}
changeColor();
}
function changeDown()
{
var div= document.getElementById('div1');
div.style.height=(parseInt(div.style.height)-8).toString()+'px';
div.style.width=(parseInt(div.style.width)-8).toString()+'px';
if(parseInt(div.style.height)==0)
{
clearInterval(handleDown);
showUp();
}
changeColor();
}
function showUp()
{
handleUp=setInterval("changeUp()",20);
var div= document.getElementById('div1');
}
function showDown()
{
handleDown=setInterval("changeDown()",20);
}
function changeColor()
{
var div= document.getElementById('div1');
var width=parseInt(div.style.height,10);
if(width>=0&&width<=9)
{
div.style.backgroundColor='#C0C0C0';
}
else if(width>=10&&width<=19)
{
div.style.backgroundColor='lavender';
}
else if(width>=20&&width<=29)
{
div.style.backgroundColor='plum';
}
else if(width>=30&&width<=39)
{
div.style.backgroundColor='highlight';
}
else if(width>=40&&width<=49)
{
div.style.backgroundColor='goldenrod';
}
else if(width>=50&&width<=59)
{
div.style.backgroundColor='Fuchsia';
}
else if(width>=60&&width<=69)
{
div.style.backgroundColor='slategray';
}
else if(width>=70&&width<=99)
{
div.style.backgroundColor='#9999FF';
}
else if(width>=100&&width<=139)
{
div.style.backgroundColor='#003333';
}
else if(width>=140&&width<=159)
{
div.style.backgroundColor='tomato';
}
else if(width>=160&&width<=179)
{
div.style.backgroundColor='deepskyblue';
}
else if(width>=180&&width<=210)
{
div.style.backgroundColor='hotpink';
}
}
</script>
</head>
<body>
<input type="button" onclick="showUp();this.disabled='disabled'" value="click me!"/><br />
<div id="div1" style="margin-left:auto; margin-right:auto; width:0px; height:0px;"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
var handleUp;
var handleDown;
function changeUp()
{
var div= document.getElementById('div1');
if(parseInt(div.style.height)<=200)
{
div.style.height=(parseInt(div.style.height)+8).toString()+'px';
div.style.width=(parseInt(div.style.width)+8).toString()+'px';
}
else if(parseInt(div.style.height)>200)
{
clearInterval(handleUp);
showDown();
}
changeColor();
}
function changeDown()
{
var div= document.getElementById('div1');
div.style.height=(parseInt(div.style.height)-8).toString()+'px';
div.style.width=(parseInt(div.style.width)-8).toString()+'px';
if(parseInt(div.style.height)==0)
{
clearInterval(handleDown);
showUp();
}
changeColor();
}
function showUp()
{
handleUp=setInterval("changeUp()",20);
var div= document.getElementById('div1');
}
function showDown()
{
handleDown=setInterval("changeDown()",20);
}
function changeColor()
{
var div= document.getElementById('div1');
var width=parseInt(div.style.height,10);
if(width>=0&&width<=9)
{
div.style.backgroundColor='#C0C0C0';
}
else if(width>=10&&width<=19)
{
div.style.backgroundColor='lavender';
}
else if(width>=20&&width<=29)
{
div.style.backgroundColor='plum';
}
else if(width>=30&&width<=39)
{
div.style.backgroundColor='highlight';
}
else if(width>=40&&width<=49)
{
div.style.backgroundColor='goldenrod';
}
else if(width>=50&&width<=59)
{
div.style.backgroundColor='Fuchsia';
}
else if(width>=60&&width<=69)
{
div.style.backgroundColor='slategray';
}
else if(width>=70&&width<=99)
{
div.style.backgroundColor='#9999FF';
}
else if(width>=100&&width<=139)
{
div.style.backgroundColor='#003333';
}
else if(width>=140&&width<=159)
{
div.style.backgroundColor='tomato';
}
else if(width>=160&&width<=179)
{
div.style.backgroundColor='deepskyblue';
}
else if(width>=180&&width<=210)
{
div.style.backgroundColor='hotpink';
}
}
</script>
</head>
<body>
<input type="button" onclick="showUp();this.disabled='disabled'" value="click me!"/><br />
<div id="div1" style="margin-left:auto; margin-right:auto; width:0px; height:0px;"></div>
</body>
</html>
作者:Cat Qi
出处:http://qixuejia.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://qixuejia.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2009-09-17 DOM的核心: Node
2009-09-17 nodeName、nodeValue 以及 nodeType 简单解析