Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 suggestions will be helpful !

EDIT:

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

like image 455
Aakash Chakravarthy Avatar asked Feb 08 '26 04:02

Aakash Chakravarthy


1 Answers

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

like image 171
Val Avatar answered Feb 12 '26 05:02

Val



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!