向下滚动页面时如何添加计数器更新 [英] how to add a counter updating when you scroll down a page

查看:64
本文介绍了向下滚动页面时如何添加计数器更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您向下滚动页面时,如何添加计数器更新?我喜欢chartbeat的效果.我应该使用什么jQuery来实现这一目标?

How can I add a counter updating when you scroll down a page? I like the effect that chartbeat has. What jQuery should I use to be able to achieve that?

推荐答案

scrollTop()函数.您将事件处理程序绑定到文档上的滚动"事件,然后将值放置在所需的位置.

There is scrollTop() function. You bind event handler to 'scroll' event on document and put the value in place you want.

$(document).ready(function() {
  $(this).bind('scroll', function() {

    console.log($(this).scrollTop());
  });
});

这篇关于向下滚动页面时如何添加计数器更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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