它工作得很好,但是当我向下滚动页面时,我希望我的div在页脚停下来。我应该在令人兴奋的代码中添加什么使其停止在footer上?
$( document ).ready(function() {
var setState = function() {
if(length > yPos && width > xPos){
//use the fixed sidebar state
$('#sidebar-fluid').hide();
$('#sidebar-fixed').show();
}else{
//use the fluid sidebar state
$('#sidebar-fluid').show();
$('#sidebar-fixed').hide();
}
}
var xPos = 683;
var yPos = 240;
var length = $(window).scrollTop();
var width = $(window).width();
$( window ).scroll(function (event) {
length = $(window).scrollTop();
setState();
});
$( window ).resize(function() {
width = $(window).width();
setState();
});
});