jquery怎样才能确定滚动事件的方向


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<style>

html,body {

height: 300%

}

div {

position: fixed;

padding-left: 10px;

padding-top: 30px;

height: 10%;

width: 35%;

font-weight: bold;

border: 2px solid red;

}

</style>

</head>

<body>

<div></div>

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>

<script>

var position = $(window).scrollTop();

$(window).scroll(function() {

var scroll = $(window).scrollTop();

if(scroll > position) {

console.log('scrollDown');

$('div').text('向下滚动');

} else {

console.log('scrollUp');

$('div').text('向上滚动');

}

position = scroll;

});

</script>

</body>

</html>

相关免费学习推荐:JavaScript(视频)

以上就是jquery怎样才能确定滚动事件的方向的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

jQuery怎么判断单选按钮是否选中

jQuery如何解除事件绑定?

jQuery是干嘛的

jQuery file是什么意思

jQuery :lang()怎么用

jQuery判断是否存在class的方法

jQuery可以删除所有的子元素吗?

jQuery如何判断是否按下了enter键

jQuery easyui 乱码怎么办

jQuery怎么判断元素是否在数组中

更多相关阅读请进入《jQuery》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...