How to determine when an HTML5 element has been viewed?

前端 未结 4 1704
小鲜肉
小鲜肉 2020-12-10 09:21

I am wondering if there are any HTML5 events associated with whether or not an element has been viewed or \"scrolled into view\" by the user.

An example could be a l

4条回答
  •  轮回少年
    2020-12-10 09:38

    As already mentioned, there is no "event" but someone already wrote a method to "detect if a DOM Element is Truly Visible" (the title). It doesn't require JQuery. You might want to check for the value on several events like the document load, scroll or window resize.

提交回复
热议问题