2014-10-07 43 views
0

我試圖在頁面底部添加一個滑動橫幅,但橫幅開始打開而不是關閉。我怎樣才能讓它開始關閉?jquery slide banner start close

JsFiddle here

$(function() { 
    var open = false; 
    $('#footerSlideButton').click(function() { 
     if(open === false) { 
      $('#footerSlideContent').animate({ height: '300px' }); 
      $(this).css('backgroundPosition', 'bottom left'); 
      open = true; 
     } else { 
      $('#footerSlideContent').animate({ height: '0px' }); 
      $(this).css('backgroundPosition', 'top left'); 
      open = false; 
     } 
    });   
}); 
+0

我也意識到,橫幅只關閉第二次嘗試點擊關閉按鈕/酒吧 – 2014-10-07 17:15:30

+0

確定通過將第二行上的「false」更改爲「true」來解決2點擊事件。我不知道它做了什麼,但它現在的工作只需點擊一下。但開始關閉問題我不知道如何解決它..:S我是新手在jquery – 2014-10-07 17:24:26

回答

0
<div id="footerSlideContent" style="height: 300px;"> 

你有內嵌的風格,覆蓋你的CSS規則。刪除。

+0

非常感謝你@Syahrul:D – 2014-10-07 18:15:18

+0

不客氣:D – slashsharp 2014-10-07 18:16:29