开发者

Jquery check whether element is hidden (continuously)

How to check whether a element is made to hide at once. i.e how to notify the visibility of an element.

In my case, the element is made to hide by slideUp function. At once i should be notified about the visibility of the that element.

I got the idea of using bind() method. But it does not have a onHide like event. So how to get like this ? any sug开发者_C百科gestions will be helpful !

EDIT:

I know it is possible to use is(':hidden') but i want to check continuously like addEventListener


if($('#selector').is(':visible')){
   //is visible
}else{
  //is NOT visible threfore is hidden
}

EDIT if that does not exist then you will have to check for opacity/filter property

so

if($('#selector').css('opacity')!=0){
       //is visible//or partially visible//depends on opacity
    }else{
      //is NOT visible threfore is hidden
    }

also make sure you check opacity cross browser

EDIT 2

function checkVisibility(){
   //put the visibility checker here
   setTimeout('checkVisibility',1000)//every 1 second...
}

note: that repetitions like this MIGHT slow down the browser


You could use slideUp's callback to know at once when the element is hiden:

function theElementIsHidden()
{
    //What to do when the slideUp animation (element hidden) is completed...
}

$("#element").slideUp(200, function(){theElementIsHidden();}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜