这是我的代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
&#13;
$(function () {
$('a').click(function (e) {
e.preventDefault();
$('div').slideUp();
$("#box_" + $(this).attr("href")).slideDown();
$(this).addClass("active");
return false;
});
});
&#13;
.hide{
display:none;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="01">Open Box 01</a>
<div id="box_01" class="hide">
Box 01
</div>
<a href="02">Open Box 02</a>
<div id="box_02" class="hide">
Box 02
</div>
&#13;