Fire event when div is visible to visitor with jQuery?

前端 未结 4 1016
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 04:08

The function: I want to change the class of a certain item when a user see a certain div (scrolls down to it).

How I do it now: I\'

4条回答
  •  心在旅途
    2021-01-01 04:25

    By looking at the source code of the jquery-appear plugin, it is possible to pass the argument one, to fire the event one time only (one: true), or every time it appears (one: false)

    $('#myDiv').appear(function() {
        $("#aDiv").addClass("active");
    }, {
        one: false
    });
    

提交回复
热议问题