|
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.clsUL { cursor:hand;
}
</style>
<script src="Scripts/jquery-1.2.6.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function(){$('#unord li').click(function() {
$(this).children('ul').slideToggle("slow");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ul id="unord" class="clsUL">
<li>Client-Side Languages
<ul>
<li>
jQuery
</li>
<li>
JavaScript
</li>
<li>
JScript
</li>
</ul>
</li>
<li>Server-Side Languages
<ul>
<li>
C#
</li>
<li>
VB.NET
</li>
<li>
Others
</li>
</ul>
</li>
</ul>
</div>
</form>
</body>
</html>
The code shown above, collapses and expands the section of <li> kept inside <ul>. Needless to say, jQuery rocks!
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |





comments
3 Responses to "Toggle Ordered/ Unordered List Using jQuery"Very very helpful.Thanks.
By far the easiest to use i've seen. 1 question - how to collapse all at initial page load?
I'd also like to know how to collapse all on initial load.
Post a Comment