 <p>The if statement is not reachable because you always showed <code>button1content</code></p> <pre><code> $('#button1content').toggle('show'); </code></pre> <p>So <code>var wasVisible = $("#button1content").is(":visible");</code> will always result to true</p>