js实现小特效 下拉菜单的折叠

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>展开菜单</title>
<link rel="stylesheet" type="text/css" href="张开菜单.css">
<script type="text/javascript" src="zhankaicaidan.js"></script>
</head>
<body>
<ul id="menu">  
<div id="list" >播放列表<span class="spanDown" id='spanId'></span></div>
<li class="lc1"><a href="#">玩爱之徒-蔡依林</a></li>
<li class="lc1"><a href="#">原谅我就是这样的女王</a></li>
<li class="lc1"><a href="#">猜不透-叮当</a></li>
<li class="lc1"><a href="#">自导自演-周杰伦</a></li>
<li class="lc1"><a href="#">浪漫窝-弦子</a></li>
<li class="lc1"><a href="#">流年-王菲</a></li>
</ul>

</body>

</html>


'use strict';
// alert("ha");
window.οnlοad=function ()
{
var oLi=document.getElementById('list');
var oSpan=document.getElementsByClassName('spanDown')[0];
var o=document.getElementById('menu');


// console.log(oUlLi[0].className);
// console.log(oUlLi[4].className);
var i=0;
oLi.οnclick=function ()

if(oSpan.className=='spanUp')
{  var oUlLi=document.getElementsByClassName('lc2');
console.log(oUlLi.length);  
console.log("chandu:"+oUlLi.length);
// console.log("chandu:"+oUlLi.length);
oSpan.className='spanDown';

o.id='menu';
// alert(oUlLi.length);
for(i=0;i<6;i++)
{
// console.log(oUlLi.length);
// if(oUlLi.length>0)
oUlLi[0].className='lc1';  


}
}
else
{ var oUlLi=document.getElementsByClassName('lc1');
console.log(oUlLi.length);
oSpan.className='spanUp';
o.id='menu1';
// alert(oUlLi.length);

for(i=0;i<6;i++)
{
// oUlLi[0].className='';
oUlLi[0].className='lc2';
console.log('ha');
}


}
}


}


#menu
{  margin: 40px auto;
background-color: #e9edf2;

list-style: none;
width: 200px;
padding-left: 0;
height: 175px;
color: #57646e;
position: relative;   




}
#menu1
{  margin: 40px auto;
background-color: white;

list-style: none;
width: 200px;
padding-left: 0;
height: 175px;
color: #57646e;
position: relative;   




}
#list
{
/* background-color: ; */
background-color: #dee3e6;


}


.spanDown
{ background-image:url(img/up.gif);
  background-repeat: no-repeat;
  width: 10px;
  height: 5px;
  position: absolute;
  left:150px;
  top: 10px;


}
.spanUp
{ background-image:url(img/down.gif);
  background-repeat: no-repeat;
  width: 10px;
  height: 5px;
  position: absolute;
  left:150px;
  top: 10px;
  /* top: px; */
  /* background-color: red; */


}


/* .spanUp img
{


 background-image: url(img/down_list_h2_bg.gif);
  background-repeat: no-repeat;
  width: 10px;
  height: 5px;
  position: relative;
  left: 100px;
} */




ul li,ul div
{  /* position: absolute; */ 
height: 25px;
/* margin:auto 0; */
/* background-color: red; */
/* width: 200px; */
/* padding-left: 0; */
/* background-color: red; */




}
ul li a
{
text-decoration: none;
}
ul .lc1:hover
{background-color: white;
  text-decoration: underline;
}
.lc2
{
display: none;
background-color: white;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值