I found this little bit of code in a project:
if ($(".c1 .c2").is(":hidden")){
$(".c1").hide();
} else {
$(".c1").show();
}
It seems quite tautological to me, since it semme to hide something if it hidden, or show it otehrwise. The only thing is the difference in selectors used, so there is some possible side effect. Changing it:
if ($(".c1").is(":hidden")){
$(".c1").hide();
} else {
$(".c1").show();
}
it would really do nothing, right?
Related HTML is as follow:
<span class="c1">
<span> </span>
<span class="c2"> </span>
</span>
CSS as follow
.c1{ display: none; }
This line:
Is not checking if
.c1is hidden, but is rather checking if.c2(which must be a descendant of.c1element, per the selector) is hidden.Therefore it is essentially acting on the parent based on the status of the child.