感谢您给我获得帮助的机会。
我想创建一个切换页脚(幻灯片面板)。
我发现下面的代码工作正常,但我希望能够使用两个不同的按钮关闭页脚:我用来打开的相同图像(#footer_button)和放置在内容内的另一个图像(十字)(#页脚内容)。
我应该如何继续将此图像 (#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>
最佳答案
您可以像 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>
关于javascript - 页脚切换带有两个用于关闭的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9452982/