滚动显示/隐藏 Div [英] Show/Hide Div on Scroll

查看:18
本文介绍了滚动显示/隐藏 Div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于幻灯片底部的 div,我想在用户滚动或使用向下箭头时消失,然后在滚动回顶部时重新出现.我猜这是结合了 jquery 滚动功能?

解决方案

<div class="a">一个

</div>$(窗口).滚动(功能(){如果 ($(this).scrollTop() > 0) {$('.a').fadeOut();} 别的 {$('.a').fadeIn();}});

示例

I have a div that sits at the bottom of a slideshow that I want to disappear when the user scrolls or uses down arrow then reappears when scrolls back to the top. I am guessing this is incorporating the jquery scroll functionality?

解决方案

<div>
  <div class="a">
    A
  </div>
</div>​


$(window).scroll(function() {
  if ($(this).scrollTop() > 0) {
    $('.a').fadeOut();
  } else {
    $('.a').fadeIn();
  }
});

Sample

这篇关于滚动显示/隐藏 Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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