Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are mixing <code>id</code>s (that have to be unique - you are using them multiple times) and <code>classes</code> in a weird way (you did before your edit...).</p> <p>For a basic setup like:</p> <pre><code>&lt;div id="container"&gt; &lt;div id="tabbox"&gt; &lt;a href="#A" class="tab"&gt;A&lt;/a&gt; &lt;!-- note the URL fragments pointing to actual ids --&gt; &lt;a href="#B" class="tab"&gt;B&lt;/a&gt; &lt;a href="#C" class="tab"&gt;C&lt;/a&gt; &lt;a href="#D" class="tab"&gt;D&lt;/a&gt; &lt;/div&gt; &lt;div id="panel"&gt; &lt;div id="A" class="tab"&gt;A Content&lt;/div&gt; &lt;!-- ID attributes are only used once --&gt; &lt;div id="B" class="tab"&gt;B Content&lt;/div&gt; &lt;div id="C" class="tab"&gt;C Content&lt;/div&gt; &lt;div id="D" class="tab"&gt;D Content&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;​​​​​​​​​​​​​​​​ </code></pre> <p>You could just use some lines of jQuery to get things working:</p> <pre><code>$('div.tab').hide().first().slideDown(); //show first $('a.tab').click(function(){ var targetID = $(this).attr('href'); //store element that triggered the click event $('div.tab:visible').slideUp(function(){ //hide visible tab $(targetID).slideDown(); //slide down newly selected tab }); });​ </code></pre> <p>See <strong><a href="http://jsfiddle.net/BkATJ/2/" rel="nofollow">a working fiddle</a></strong></p> <p>Also read about <strong><a href="https://developer.mozilla.org/en/DOM/element.id" rel="nofollow">ids</a></strong> and <strong><a href="https://developer.mozilla.org/En/CSS/Class_selectors" rel="nofollow">classes</a></strong> at MDN</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload