javascript - How to check if HTML element is/is not hidden? -


this question has answer here:

i have 2 elements(setproject , sethdc). when clicked, show other table elements. want make 1 group of table elements appear @ same time. example when user clicked on "setproject", "sethdc" element must hidden. , same otherwise. there way can if statment? or there simpler way it?

<script>  $(document).ready(function(){   $("#setproject ").click(function(){     $("#test1").fadetoggle("fast");     $("#projecttable1").fadetoggle("fast");     $("#projecttable2").fadetoggle("fast");     $("#projecttable3").fadetoggle("fast");   }); }); $(document).ready(function(){   $("#sethdc").click(function(){     $("#hdctable1").fadetoggle("fast");     $("#hdctable2").fadetoggle("fast");   }); }); </script> 

you should use

 if($(this).is(':visible')){      dosomething();  }else{      dosomethingelse();  } 

the else part work elements display:none. elements have visibility:hidden/opacity:0 considered visible


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -