0
我为每个div获得了一个侧边栏,我想通过向下滚动固定来获得所有侧边栏。几个div中的粘边栏
,你可以在这里找到它
var tmpWindow = $(window),
sidebar = $('.sidebar'),
sidebarHeight = sidebar.height(),
offsetBottom = $('.content').outerHeight();
$(window).scroll(function() {
if ($(window).scrollTop() >= sidebarHeight) {
$('.sidebar').addClass('fixed');
alert(sidebarHeight);
} else {
$('.sidebar').addClass('fixed');
}
});
如果我使用它会消失的JS ...
你应该把你的alert()出来并使用console.log()它可能会帮助 – m33bo