http://jsfiddle.net/eRtP3/李並不裏面UL
顯示我有菜單,裏面裏,還有另外一個UL,對UL顯示的李點擊時。但這個jQuery不工作。
$(document).ready(function() {
$("#side-nav .sub-menu").click(function() {
//slide up all the link lists
$("#side-nav ul ul").slideUp();
//slide down the link list below the h3 clicked - only if its closed
if (!$(this).next().is(":visible")) {
$(this).next().slideDown();
}
})
})
HTML
<div id="side-nav">
<ul>
<li style="border-top: thin #eee solid;" class="sub-menu">
<i class="fa fa-upload fa-lg"></i>Upload
<ul>
<li><a href="#">Link1</a>
</li>
<li><a href="#">Link2</a>
</li>
<li><a href="#">Link3</a>
</li>
</ul>
</li>
<li><a href="~/Log/Index"><i class="fa fa-list fa-lg"></i>Log</a>
</li>
</ul>
</div>
CSS
#side-nav ul ul {
display: none;
}
#side-nav li.active ul {
display: block;
}
Johny:謝謝。但滑動不起作用 – neel
@Parvathiiiii而不是'.slideDown();'使用'.slideToggle();' - http://jsfiddle.net/arunpjohny/C4MMA/2/ –