我對jquery相當陌生,並儘量學習。最難的部分是知道要應用什麼。我試圖找到合乎邏輯的方法,但大多數時候都很難找到。試圖刪除菜單中的div
1.我附有圖片描述我在這裏的第一個問題http://tinypic.com/r/8xka3c/7
2.我的第二個問題是如何避免選擇按鈕來切換?我只想讓它在按另一個按鈕時將 恢復到正常狀態。
我真的很感謝你的幫忙!
我的代碼:
$(document).ready(function() {
var $div = $('#test');
var height = $div.height();
$div.hide().css({ height : 0 });
$('li#contact').click(function() {
if ($div.is(':visible')) {
$div.animate({ height: 0 }, { duration: 250, complete: function() {
$div.hide();
} });
} else {
$div.show().animate({ height : height }, { duration: 250 });
}
return false;
});
});
$('#nav li').click(function() {
$('#nav li').not(this).removeClass('active');
$(this).toggleClass('active');
});
要添加到什麼卡里姆說,我認爲你最後單擊處理程序應該是$(文件)。就緒()(我知道這是不是一個「答案」,但我不能在發表評論呢。) – dcastro