jQuery event to trigger action when a div is made visible

后端 未结 22 2616
你的背包
你的背包 2020-11-22 12:03

I\'m using jQuery in my site and I would like to trigger certain actions when a certain div is made visible.

Is it possible to attach some sort of \"isvisible\" even

22条回答
  •  忘掉有多难
    2020-11-22 12:26

    I had this same problem and created a jQuery plugin to solve it for our site.

    https://github.com/shaunbowe/jquery.visibilityChanged

    Here is how you would use it based on your example:

    $('#contentDiv').visibilityChanged(function(element, visible) {
        alert("do something");
    });
    

提交回复
热议问题