我的问题是通过编辑以前给定的代码来解决的。但现在我面临一个不同的问题。因为我的 HTML 代码是:
<body>
<ul>
<li><a href="#">Academic Programme</a>
<ul>
<li><a href="#">Under Graduate</a></li>
<li><a href="#">Post Graduate</a></li>
<li><a href="#">Ph. D</a></li>
</ul>
</li>
<li><a href="#">People</a>
<ul>
<li><a href="#">Director</a>
<li><a href="#">Faculty</a>
<ul>
<li><a href="#">Computer Engineering</a></li>
<li><a href="#">Information Technology</a></li>
<li><a href="#">Electronics & Communication Engineering</a></li>
<li><a href="#">Civil Engineering</a></li>
<li><a href="#">Mechanical Engineering</a></li>
<li><a href="#">Automobile Engineering</a></li>
<li><a href="#">Electrical Engineering</a></li>
</ul>
<li><a href="#">Technical Staff</a>
<li><a href="#">Administrator Staff</a>
<li><a href="#">Supporting Staff</a>
</ul>
</li>
<li><a href="#">Department</a>
<ul>
<li><a href="#">Computer Engineering</a></li>
<li><a href="#">Information Technology</a></li>
<li><a href="#">Electronics & Communication Engineering</a></li>
<li><a href="#">Civil Engineering</a></li>
<li><a href="#">Mechanical Engineering</a></li>
<li><a href="#">Automobile Engineering</a></li>
<li><a href="#">Electrical Engineering</a></li>
</ul>
</li>
<li><a href="#">Amenities</a></li>
<li><a href="#">Library
<li><a href="#">Admission</a>
<ul>
<li><a href="#">UTU</a></li>
<li><a href="#">GTU</a></li>
</ul>
</li>
<li><a href="#">Student Corner</a></li>
<li><a href="#">Circular</a></li>
<li><a href="#">News&Events</a></li>
</ul>
我的jQuery是:
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('li').click(function(ev) {
ev.stopPropagation();
$(this).children('ul').fadeIn();
$(this).prev().children('ul').children('li').children('ul').fadeOut();
$(this).prev().children('ul').fadeOut();
$(this).next().children('ul').fadeOut();
$(this).next().children('ul').children('li').children('ul').fadeOut();
});
$('li > ul').hide();
});
</script>
But now i am facing problem of prev and next. Suppose in given HTML form if i had expnaded people then if i will expand admission then people is not collapsed so do any have alternative for prev() and next(). Thank you.