我試圖建立一個菜單按鈕,它既打開我的菜單,也同時觸發其他命令。用jQuery切換多個命令
單擊按鈕時,應打開菜單,背景變爲紅色。
當再次點擊按鈕時,菜單應該關閉,背景變成綠色。
http://test.bsley.com/rest/menu3/
任何幫助,將不勝感激!
的jQuery:
$(document).ready(function() {
$("#trigger").click(function() {
if ($(this).css('background-color') == 'red') {
alert("test");
} else {
$("#panel").slideDown("fast");
$("body").css("background-color", "red");
}
});
});
HTML:
<div id="panel">Here is the menu</div> <div id="trigger">+ Menu</div>
問題是菜單無法關閉並且背景顏色變爲綠色這一事實? – pablofiumara
@pablofiumara是的先生!對不起,沒有代碼在第一個傢伙。 –