切换
来源:互联网 发布:爰淘宝 编辑:程序博客网 时间:2024/05/16 01:11
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title></title>
<styletype="text/css">
.show{
width:100px;
height:100px;
background-color: red;
font-size:50px;
color: white;
display:block;
}
div{
display:none;
}
.active{
width:50;
height:20px;
background-color: yellow;
}
</style>
</head>
<body>
<inputtype="button" name="" id=""value="按钮1" />
<inputtype="button" name="" id=""value="按钮2" />
<inputtype="button" name="" id=""value="按钮3" />
<div class="show">A</div>
<div>B</div>
<div>C</div>
<scripttype="text/javascript">
varaDiv = document.getElementsByTagName("div");
var aInput = document.getElementsByTagName("input");
// // 按钮1
// aInput[0].onclick = function (){
// for (var i = 0; i < aInput.length; i++) {
// aInput[i].className = "";
// aDiv[i].className = "";
// }
// aDiv[0].className = "show";
// aInput[0].className = "active";
// }
//
// aInput[1].onclick = function (){
// for (var i = 0; i < aInput.length; i++) {
// aInput[i].className = "";
// aDiv[i].className = "";
// }
// aDiv[1].className = "show";
// aInput[1].className = "active"; nn
// }
// aInput[2].onclick = function (){
// for (var i = 0; i < aInput.length; i++) {
// aInput[i].className = "";
// aDiv[i].className = "";
// }
// aDiv[2].className = "show";
// aInput[2].className = "active";
// }
// 为了绑定事件循环三次
for(var i = 0; i< aInput.length; i++) {
// 给input标签添加一个属性index 用于保存他的下标
aInput[i].index= i;
aInput[i].onclick= function (){
for(var j = 0; j< aInput.length; j++) {
// 先清除样式,再加样式
aInput[j].className= "";
aDiv[j].className= "";
}
this.className= "active";
aDiv[this.index].className= "show";
}
}
</script>
</body>
</html>
- 切换
- 切换
- 切换
- 切换
- 切换
- 切换
- 切换进程 切换线程
- 视图切换
- 切换输入法
- js切换
- 切换视图
- tab切换
- 程序切换
- 图片切换
- 图片切换
- 切换tab
- 简繁体切换
- 软切换
- Python中re.compile遇到only supports 100 named groups的问题
- 空心菱形
- Leet常用数据结构【LeetCode】
- 最大公约数,最小公倍数
- springboot与jdbc
- 切换
- 数字反转(升级版)
- 解释器模式 详解
- 下拉列表小例子
- rabbitmq 消息确认机制
- numpy module 1 -- Numpy tutorial
- [Cloud Computing]Mechanisms: Endpoint Threat Detection and Response
- 最少硬币问题
- 返回数组最大值