我有一組div對('header'和'body')。當用戶點擊標題時,下一個正文部分應該顯示/隱藏(並更新+/-圖標)。所有的div都被寫成在頁面加載時「顯示」,但我想「關閉」其中一些div,如果用戶願意,用戶可以打開它們。只是不能得到它的工作!代碼如下,如果任何人都可以幫忙!切換不起作用
樣品部分:
<div class="expandingSection_head" id="expanderAI">
<img class="imgExpand" src="../images/treeExpand_plus.gif" />
Header text here
</div>
<div class="expandingSection_body">
body text here
</div>
...more pairs of divs like this on rest of page...
代碼切換:
$(".expandingSection_head").toggle(
function() {
$(this).css('background-color', '#6BA284');
$(this).find('.imgExpand').attr('src', '../images/treeExpand_plus.gif');
$(this).next(".expandingSection_body").slideUp(400);
},
function() {
$(this).css('background-color', '#6BA284');
$(this).find('.imgExpand').attr('src', '../images/treeExpand_minus.gif');
$(this).next(".expandingSection_body").slideDown(400);
});
$("#expanderAI").toggle();
最後一行沒有 「切換」 指定的div(即 「關閉」 的話)。有人知道爲什麼可能有些簡單。
謝謝!
是背景顏色和圖像切換? – Patricia 2010-08-06 14:15:08
不幸的是,沒有:( – jqwha 2010-08-06 14:17:30
你有沒有得到這個工作? – Patricia 2010-08-09 13:12:18