<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>menu tree</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<ul class="menu">
<li>
<a href="#">A1</a>
<ul>
<li><a href="#">A1-1</a></li>
<li><a href="#">A1-2</a></li>
<li>
<a href="#">A1-3</a>
<ul>
<li><a href="#">A1-3-1</a></li>
<li><a href="#">A1-3-2</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">A2</a>
<ul>
<li><a href="#">A2-1</a></li>
<li><a href="#">A2-2</a></li>
</ul>
</li>
<li><a href="#">A3</a></li>
</ul>
<body>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".menu ul").css("display","none");
$(".menu a").on("click", function(){
$(this).next().toggle();
});
});
</script>
</body>
</html>
注:jQuery的版本为v1.11.0