2012-02-26 48 views
1

謝謝你給我機會得到幫助。頁腳切換兩個圖像關閉

我想創建一個切換頁腳(滑動面板)。

我發現下面的代碼工作正常,但我希望能夠關閉頁腳與兩個不同的按鈕:我用來打開(#footer_button)和另一個圖像(十字)放在內容( #footer_content)。

我應該如何繼續使用此代碼在此圖像(#footer_button_2)上集成相同的功能?

非常感謝提前!

這裏是一個打印屏幕:http://hpics.li/cb5b88a

這裏是我使用的代碼:

<script type="text/javascript"> 
jQuery(function($) { 
var slide = false; 
var height = $('#footer_content').height(); 
$('#footer_button').click(function() { 
    var docHeight = $(document).height(); 
    var windowHeight = $(window).height(); 
    var scrollPos = docHeight - windowHeight + height; 
    $('#footer_content').animate({ height: "toggle"}, 1000); 
    if(slide == false) { 
     if($.browser.opera) { //Fix opera double scroll bug by targeting only HTML. 
      $('html').animate({scrollTop: scrollPos+'px'}, 1000); 
     } else { 
      $('html, body').animate({scrollTop: scrollPos+'px'}, 1000); 
     } 
          slide = true; 
    } else { 
          slide = false; 
        } 
}); 
}); 
</script> 

回答

0

您可以將它們與昏迷像CSS分開:$( '#footer_button,#CrossImgID'):)

<script type="text/javascript"> 
jQuery(function($) { 
var slide = false; 
var height = $('#footer_content').height(); 
$('#footer_button, #CrossImgID').click(function() { 
    var docHeight = $(document).height(); 
    var windowHeight = $(window).height(); 
    var scrollPos = docHeight - windowHeight + height; 
    $('#footer_content').animate({ height: "toggle"}, 1000); 
    if(slide == false) { 
     if($.browser.opera) { //Fix opera double scroll bug by targeting only HTML. 
      $('html').animate({scrollTop: scrollPos+'px'}, 1000); 
     } else { 
      $('html, body').animate({scrollTop: scrollPos+'px'}, 1000); 
     } 
          slide = true; 
    } else { 
          slide = false; 
        } 
}); 
}); 
</script> 
+0

太謝謝你了,阿達斯!你搖滾!它現在工作正常! – 2012-02-26 12:37:50

+0

不用擔心!那麼,你能接受這個問題嗎? – Adaz 2012-02-26 12:51:29