Trigger event when user scroll to specific element - with jQuery

后端 未结 12 1452
攒了一身酷
攒了一身酷 2020-11-22 11:52

I have an h1 that is far down a page..

TRIGGER EVENT WHEN SCROLLED TO.

and I want to trigger an alert

12条回答
  •  故里飘歌
    2020-11-22 12:57

    You can use jQuery plugin with the inview event like this :

    jQuery('.your-class-here').one('inview', function (event, visible) {
        if (visible == true) {
          //Enjoy !
        }
    });
    

    Link : https://remysharp.com/2009/01/26/element-in-view-event-plugin

提交回复
热议问题