我有一个简单的问题。我开发了一些使用slideToggle折叠并扩展为 DIV 的代码。我现在要做的是显示/隐藏相应的展开和折叠图像。
.html页面:
<li>
<div class="toggle_head togglebackground">
 <img src="images/expand.png" alt="Expand" id="expand" class="expand">
 <img src="images/collapse.png" alt="Collapse" id="collapse" class="collapse">
<label> Cookies</label>
</div>
<div class="box toggle_body">
<ul class="list">
<li>
<label disabled="disabled">Information about cookies.....</label>
</li>
</ul>
</div>
<!-- !END section (Cookies) -->
</li>
<li>
<div class="toggle_head togglebackground">
 <img src="images/expand.png" alt="Expand" id="expand" class="expand">
 <img src="images/collapse.png" alt="Collapse" id="collapse" class="collapse">
<label> Terms</label>
</div>
<div class="box toggle_body">
<ul class="list">
<li>
<label disabled="disabled">Information about terms and conditions.....</label>
</li>
</ul>
</div>
<!-- !END section (Terms) -->
</li>
jQuery代码:
$( document ).ready(function() {
//hide the all of the element with class msg_body
$(".toggle_body").hide();
$(".collapse").hide();
//toggle the componenet with class msg_body
$(".toggle_head").click(function()
{
$(this).next(".toggle_body").slideToggle(300);
//$(".collapse").show();
//$(this).next(".collapse").show();
});
});
谢谢