JavaScript/jQuery add class when element comes into viewport?

后端 未结 2 2032
囚心锁ツ
囚心锁ツ 2021-01-20 23:34

Is there a way to add a class when the element that I want to apply the class to comes into the viewport? Or when the bottom of the screen is a certain distance past the top of

2条回答
  •  心在旅途
    2021-01-20 23:42

    You're on the right track, I think if you use the scroll event with a function such as the answer to this similar question:

    Check if element is visible after scrolling

    Hope that helps :)

提交回复
热议问题