JSP 要怎么做成这样的下拉菜单 10
1个回答
展开全部
html:
<div class="leftpart">
<div class="tree">
<p class="tree-title"><em class="down"></em>sadasd</p>
<ul class="tree-main on">
<li><em class=" "></em>192.168.1.111</li>
<li><em></em>192.168.1.112</li>
</ul>
</div>
<div class="tree">
<p class="tree-title"><em class="down"></em>asda</p>
<ul class="tree-main">
<li><em></em>192.168.1.121</li>
<li><em></em>192.168.1.122</li>
</ul>
</div>
</div>
css:
.tree-title{
padding: 7px 10px;
cursor:pointer;
}
.tree-title:hover{
background:#f5f5f5;
}
.tree-title em,.tree-main li em{
display: inline-block;
width: 14px;
height: 14px;
margin-right: 5px;
}
.tree-title em.down{
background: url(../images/down.png) center no-repeat;
-webkit-background-size: 14px;
background-size: 14px;
}
.tree-title em.right{
background: url(../images/ico-right.png) center no-repeat;
-webkit-background-size: 14px;
background-size: 14px;
}
.tree-main{
padding-left: 20px;
}
.tree-main li{
padding: 3px 10px;
font-size: 12px;
cursor:pointer;
}
.tree-main{
display: none;
}
.tree-main.on{
display: block;
}
JS:
$('p.tree-title').click(function(){
if($(this).children('em').hasClass('down')){
$(this).children('em').removeClass('down').addClass('right');
}else{
$(this).children('em').removeClass('right').addClass('down');
}
$(this).parent().children('ul').toggleClass('on');
});
<div class="leftpart">
<div class="tree">
<p class="tree-title"><em class="down"></em>sadasd</p>
<ul class="tree-main on">
<li><em class=" "></em>192.168.1.111</li>
<li><em></em>192.168.1.112</li>
</ul>
</div>
<div class="tree">
<p class="tree-title"><em class="down"></em>asda</p>
<ul class="tree-main">
<li><em></em>192.168.1.121</li>
<li><em></em>192.168.1.122</li>
</ul>
</div>
</div>
css:
.tree-title{
padding: 7px 10px;
cursor:pointer;
}
.tree-title:hover{
background:#f5f5f5;
}
.tree-title em,.tree-main li em{
display: inline-block;
width: 14px;
height: 14px;
margin-right: 5px;
}
.tree-title em.down{
background: url(../images/down.png) center no-repeat;
-webkit-background-size: 14px;
background-size: 14px;
}
.tree-title em.right{
background: url(../images/ico-right.png) center no-repeat;
-webkit-background-size: 14px;
background-size: 14px;
}
.tree-main{
padding-left: 20px;
}
.tree-main li{
padding: 3px 10px;
font-size: 12px;
cursor:pointer;
}
.tree-main{
display: none;
}
.tree-main.on{
display: block;
}
JS:
$('p.tree-title').click(function(){
if($(this).children('em').hasClass('down')){
$(this).children('em').removeClass('down').addClass('right');
}else{
$(this).children('em').removeClass('right').addClass('down');
}
$(this).parent().children('ul').toggleClass('on');
});
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询