jQuery窗口滚动事件? [英] JQuery window scrolling event?

查看:86
本文介绍了jQuery窗口滚动事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标题中有一个广告,页面底部始终有一个固定的广告.我希望仅当用户在标题广告下滚动时才显示固定广告.我查看了JQuery文档,但不确定如何使用.

I have an ad in my header and a fixed ad at the bottom of my page that is always there. I want the fixed ad to appear only if the user has scrolled under the header ad. I looked into the JQuery documentation, but I'm not really sure what I should use.

推荐答案

请尝试以下操作: http://jsbin.com/axaler/3/修改

$(function(){
  $(window).scroll(function(){
    var aTop = $('.ad').height();
    if($(this).scrollTop()>=aTop){
        alert('header just passed.');
        // instead of alert you can use to show your ad
        // something like $('#footAd').slideup();
    }
  });
});

这篇关于jQuery窗口滚动事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆