默认样式
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNvwVZ2x2bzNXak9CX90TQNNkRrFlQKBTSvwFbslmZvwFMwQzLcVmepNHdu9mZvwFVywUNMZTY18CX052bm9CX90EVOhXVU5EeFRVT3V1MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2LcRHelR3LcJzLctmch1mclRXY39TMyYDNycTM3EDNwcDM4EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
鼠标移上去的样式
点击以后的样式
<html>
<head>
<title>二级菜单测试</title>
<meta charset="utf-8">
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<style type="text/css">
.
.menuDiv {
border: 2px solid #aac;
overflow: hidden;
display:inline-block;
}
.menuDiv a {
text-decoration: none;
}
.menuDiv ul , .menuDiv li {
list-style: none;
margin: 0;
padding: 0;
float: left;
}
.menuDiv > ul > li > ul {
position: absolute;
display: none;
}
.menuDiv > ul > li > ul > li {
float: none;
}
.menuDiv > ul > li:hover ul {
display: block;
}
.menuDiv > ul > li > a {
width: 120px;
line-height: 40px;
color: black;
background-color: #cfe;
text-align: center;
border-left: 1px solid #bbf;
display: block;
}
.menuDiv > ul > li:first-child > a {
border-left: none;
}
.menuDiv > ul > li > a:hover {
color: #f0f;
background-color: #bcf;
}
.menuDiv > ul > li > ul > li > a {
width: 120px;
line-height: 36px;
color: #456;
background-color: #eff;
text-align: center;
border: 1px solid #ccc;
border-top: none;
display: block;
}
.menuDiv > ul > li > ul > li:first-child > a {
border-top: 1px solid #ccc;
}
.menuDiv > ul > li > ul > li > a:hover {
color: #a4f;
background-color: #cdf;
}
</style>
</head>
<body>
<!-- -------菜单html代码---------begin------- -->
<span class="font-icon" title="放大缩小" data-bind="click:btnSize">
<i class="iconfont icon-viewgallery"></i>
<div class="menuDiv">
<ul>
<li >
<a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" id="menuDivPitchOn">指标:</a>
<ul class="dropDown-menu">
<li><a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" data-val="二级菜单1">二级菜单</a></li>
<li><a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" data-val="二级菜单2">二级菜单</a></li>
<li><a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" data-val="二级菜单3">二级菜单</a></li>
</ul>
</li>
</ul>
</div>
</span>
<!-- -------菜单html代码---------end------- -->
</body>
</html>
<script type="text/javascript">
$(".menuDiv .dropDown-menu a").click(function(){
var v = $(this).attr("data-val");
var va = $(this).html();
console.log(v);
$("#menuDivPitchOn").html("指标:"+va)
});
</script>