所以我有幾個容器與此標記在頁面上:JQuery的最接近()幫助
<div class="box w400">
<div class="box-header">
<span class="expand-collapse">expand/collapse</span>
<h3>Heading</h3>
</div>
<div class="box-content">
<p>Some content here...</p>
</div>
</div>
,我試圖以實現點擊.expand崩潰跨度之後,.box的內容DIV會向上或向下滑動(切換)。
下面是我使用jQuery的,我想用最接近()來實現這一目標:
$(document).ready(function() {
$('.expand-collapse').click(function() {
$(this).closest('.box-content').slideToggle('slow');
});
});
但它不工作由於某種原因:(
也不起作用。 – 2009-08-07 01:40:17
@Richard Knop - 我編輯了答案,給它一個答案。 – karim79 2009-08-07 01:41:00
謝謝你的作品:) – 2009-08-07 01:43:07