Javascript 用于循环内部滚动功能
如何在滚动循环中使用多功能 我有:Javascript 用于循环内部滚动功能,javascript,jquery,Javascript,Jquery,如何在滚动循环中使用多功能 我有: $(window).scroll(function() { b1Center = $("#block-1").offset().top - ( $(window).height() - divHeight )/2; b1Bottom = $("#block-1").offset().top - $(window).height() b1Top = $("#block-1").offset().top + divHeight; if(getScrollTop()
$(window).scroll(function() {
b1Center = $("#block-1").offset().top - ( $(window).height() - divHeight )/2;
b1Bottom = $("#block-1").offset().top - $(window).height()
b1Top = $("#block-1").offset().top + divHeight;
if(getScrollTop() > b1Bottom && getScrollTop() < b1Top){
$("#block-1 .txt").css('marginTop', ( (getScrollTop()) *(1.6)) + 'px');
}...
$(窗口)。滚动(函数(){
b1Center=$(“#block-1”).offset().top-($(window.height()-divHeight)/2;
b1Bottom=$(“#block-1”).offset().top-$(窗口).height()
b1Top=$(“#block-1”).offset().top+divHeight;
if(getScrollTop()>b1Bottom&&getScrollTop()
这需要一直在滚动功能redy中,我对所有按钮都有相同的块,因此:
希望这会更有意义。试试这个:
$(document).ready(function(){
var divHeight = 700;
$(window).scroll(function() {
$(".blocks").each(function(){
var this = $(this),
Center = $(this).offset().top - ( $(window).height() - divHeight )/2,
Bottom = $(this).offset().top - $(window).height(),
Top = $(this).offset().top + divHeight;
if(getScrollTop() > Bottom && getScrollTop() < Top){
this.find('.txt').css('marginTop', ( (getScrollTop()) *(1.6)) + 'px');
}
});
});
});
$(文档).ready(函数(){
高度=700;
$(窗口)。滚动(函数(){
$(“.blocks”)。每个(函数(){
var this=$(this),
中心=$(此).offset().top-($(窗口).height()-divHeight)/2,
底部=$(此).offset().top-$(窗口).height(),
Top=$(this).offset().Top+divHeight;
if(getScrollTop()>Bottom&&getScrollTop()
将其放入.scrollTop()循环中:
确保使用按钮的类别而不是id…。因为这是视差,所以它不起作用,因为scoll将同时滚动所有窗口,如果我在那里滚动,则窗口中没有内容
$('.block').each(function () {
var this_block = $(this);
this_block.whateverFunction(you, want, to, do);
});