html 实现二级列表,点击会变色
来源:互联网 发布:js有没有boolean 编辑:程序博客网 时间:2024/04/28 18:08
<!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>
<style>
*{
margin:0px;
padding:0px;
}
a{
text-decoration:none;
}
h3{
font-weight:normal;
line-height:40px;
background-color:#f5f5f5;
padding-left:10px;
border-bottom:1px solid #e0dede;
color:#000;
}
section{
margin:0px 10px;
border:1px solid #e0dede;
}
p{
text-indent:2em;
padding:10px;
font-size:14px;
display:none;
}
p:target{
display:block;
}
</style>
<script>
window.onload = function(){
var divs = document.getElementsByTagName("h3");
var len = divs.length;
for(var i=0;i<len;i++){
divs[i].onclick = function(){
for(var j=0;j<len;j++){
divs[j].style.backgroundColor = "#e0dede";
}
this.style.backgroundColor = "#0FC";
};
}
};
</script>
</head>
<body>
<main>
<section>
<a href="#item1"><h3>项目一</h3></a>
<p id="item1">项目一,一</p>
</section>
<section >
<a href="#item2"><h3>项目二</h3></a>
<p id="item2">项目二,一<br /> 项目二,二</p>
</section>
<section>
<a href="#item3"><h3>项目三</h3></a>
<p id="item3">项目三,一<br /> 项目三,二<br /> 项目三,三</p>
</section>
</main>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{
margin:0px;
padding:0px;
}
a{
text-decoration:none;
}
h3{
font-weight:normal;
line-height:40px;
background-color:#f5f5f5;
padding-left:10px;
border-bottom:1px solid #e0dede;
color:#000;
}
section{
margin:0px 10px;
border:1px solid #e0dede;
}
p{
text-indent:2em;
padding:10px;
font-size:14px;
display:none;
}
p:target{
display:block;
}
</style>
<script>
window.onload = function(){
var divs = document.getElementsByTagName("h3");
var len = divs.length;
for(var i=0;i<len;i++){
divs[i].onclick = function(){
for(var j=0;j<len;j++){
divs[j].style.backgroundColor = "#e0dede";
}
this.style.backgroundColor = "#0FC";
};
}
};
</script>
</head>
<body>
<main>
<section>
<a href="#item1"><h3>项目一</h3></a>
<p id="item1">项目一,一</p>
</section>
<section >
<a href="#item2"><h3>项目二</h3></a>
<p id="item2">项目二,一<br /> 项目二,二</p>
</section>
<section>
<a href="#item3"><h3>项目三</h3></a>
<p id="item3">项目三,一<br /> 项目三,二<br /> 项目三,三</p>
</section>
</main>
</body>
</html>
阅读全文
0 0
- html 实现二级列表,点击会变色
- 实现ExpandableListView 二级列表,点击二级条目状态的改变
- 二级联动下拉列表JS+html实现
- 二级联动下拉列表JS+html实现
- 实现按钮点击变色
- HTML表格多行表头,隔行变色,点击变色的实现
- html+qjquery 实现变色
- 二级列表简单实现二级列表
- tableViewCell列表点击展开显示二级列表
- Recycle 实现二级列表
- 二级列表的实现
- 二级列表的实现
- RecyclerView实现二级列表
- gridview实现点击行变色
- jquery实现点击步骤条变色,以及点击下一步变色
- HTML实现二级菜单
- html实现二级联动
- HTML 实现伪类之input输入框鼠标点击边框变色效果
- 宏定义(一)
- 阿里巴巴盘中市值达4700亿美元;B站计划最快明年美国IPO ;NASA计划为前往火星宇航员修改DNA丨价值早报
- 图片的异步加载和适配器
- sizeof的深入理解
- memset的使用
- html 实现二级列表,点击会变色
- strcpy、memcpy的区别
- 各种字符集和编码详解
- String类和StringBuffer类的区别
- _cdecl 和_stdcall及其他调用方式 (一)
- 函数调用规范__cdecl和__stdcall的区别一目了然(表格形式)(二)
- 9月542起融资:投资界的“金九银十”,本月关键词大额、频繁丨潜在月报
- API之绘图(转)
- API之子窗口创建 (转)