javascript - How to check if HTML element is/is not hidden? -
this question has answer here:
- how check if element hidden in jquery? 48 answers
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
Post a Comment