jQuery: How to bind an event for the div when it becomes visible?

前端 未结 3 2039
予麋鹿
予麋鹿 2021-01-18 15:28

I\'ve got a div element:

Tab data
.

How to bind a custom event when this div becomes visible (gets displa

3条回答
  •  终归单人心
    2021-01-18 15:54

    Have the event always bound to the div, but inside the event, do something like the following:

    if($(self).is(":visible")){
        // Implement your code
    }
    

    Now your event will only be triggered if the element is visible to the user.

提交回复
热议问题