本文实例为大家分享了js实现QQ列表展开收缩扩展展示的具体代码,供大家参考,具体内容如下
效果图:
代码:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> ul,h2{margin:0; padding:0;} li{list-style-type:none;} #list{margin:0 auto; border:#333 solid 1px; width:250px;} #list h2 {background: url(../img/ico1.gif) no-repeat 5px 14px #0C6; text-indent:20px; height:32px; line-height:32px;} #list ul li{text-indent:25px; border-bottom:#333 solid 1px; line-height:24px; height:23px; } #list .active{background: url(../img/ico2.gif) no-repeat 5px 14px #693; text-indent:20px; height:30px; line-height:30px;} #list ul{display:none;} .hover{background:#CFC;} </style> <script> window.onload = function(){ var oUl = document.getElementById("list"); var aUl =oUl.getElementsByTagName("ul"); var aH2 = oUl.getElementsByTagName("h2"); var aLi = null; var arrLi = []; var that = null; for(i=0;i<aH2.length;i++){ aH2[i].index = i; aH2[i].onclick = function(){ if(this.className==''){ for(i=0;i<aH2.length;i++){ aH2[i].className=''; aUl[i].style.display='none'; } this.className='active'; aUl[this.index].style.display = 'block'; }else{ this.className=''; aUl[this.index].style.display='none'; } } } for(i=0;i<aUl.length;i++){ aLi =aUl[i].getElementsByTagName("li"); for(j=0;j<aLi.length;j++){ arrLi.push(aLi[j]); } } for(var i=0;i<arrLi.length;i++){ arrLi[i].onclick = function(){ for(i=0; i<arrLi.length;i++){ arrLi[i].className=''; } this.className = 'hover'; } } }; </script> </head> <body> <ul id="list"> <li class="lis"> <h2>我的好友</h2> <ul> <li>张三</li> <li>张四</li> <li>张五</li> <li>张六</li> </ul> </li> <li class="lis"> <h2>企业好友</h2> <ul> <li>李四</li> <li>李小四</li> <li>李四二</li> <li>李毅</li> <li>李二</li> </ul> </li> <li class="lis"> <h2>黑名单</h2> <ul> <li>张三</li> <li>李四</li> </ul> </li> </ul> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 群星.2022-一不小心喵上你原声大碟【TME影音】【FLAC分轨】
- 《战锤40K星际战士2》卡在正在加入服务器解决方法
- 《勇者斗恶龙怪物仙境3》玩法内容介绍
- 《幸福工厂》无限报错解决方法
- 交错战线原始交易所推荐角色一览
- 战锤40K星际战士2战术职业介绍|战术职业技能效果一览
- 战锤40K星际战士2突击职业介绍|突击职业技能效果一览
- [妙音金曲]群星《悲情咖啡屋》(黑胶)2CD[DTS-WAV]
- 阿兰·达瓦卓玛《A-Lan阿兰唯美歌姬》2CD[DTS-WAV]
- 【小提琴】陈立新《思乡曲》2004[FLAC+CUE]
- 《战地》新作明年初大规模测试!EA已内部测试一年
- 《GTAOL》PC版时隔多年更新反作弊!小助手宣布跑路
- EA称AI是其业务核心!能提高开发效率、节约成本
- 卫华.1990-太阳升【BMG】【WAV+CUE】
- 呼吸乐队.1992-THEBREATHING【深飞】【WAV+CUE】