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

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

问题描述

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

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天全站免登陆