jQuery event to trigger action when a div is made visible

后端 未结 22 2229
你的背包
你的背包 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:25

    I did a simple setinterval function to achieve this. If element with class div1 is visible, it sets div2 to be visible. I know not a good method, but a simple fix.

    setInterval(function(){
      if($('.div1').is(':visible')){
        $('.div2').show();
      }
      else {
        $('.div2').hide();
      }      
    }, 100);
    

提交回复
热议问题