Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if this is exactly what you're after, but I put together this jsFiddle for you to have a look at. See <a href="http://jsfiddle.net/qsUVZ/1/" rel="nofollow noreferrer">here</a>.</p> <p>I added a few changes so you can identify which anchors relate to which div, so my HTML looks as follows:</p> <pre><code>&lt;div id="main"&gt; &lt;div class="item"&gt;&lt;a href="#" name="a"&gt;Link to div A&lt;/a&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;a href="#" name="b"&gt;Link to div B&lt;/a&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;a href="#" name="c"&gt;Link to div C&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="item" id="a" style="display:none;"&gt; Link to div &lt;a href="#" name="b"&gt;B&lt;/a&gt; and &lt;a href="#" name="c"&gt;C&lt;/a&gt; &lt;/div&gt; &lt;div class="item" id="b" style="display:none;"&gt; Link to div &lt;a href="#" name="a"&gt;A&lt;/a&gt; and &lt;a href="#" name="c"&gt;C&lt;/a&gt; &lt;/div&gt; &lt;div class="item" id="c" style="display:none;"&gt; Link to div &lt;a href="#" name="a"&gt;A&lt;/a&gt; and &lt;a href="#" name="b"&gt;B&lt;/a&gt; &lt;/div&gt; </code></pre> <p>Then, just a simple use of jQuery and it seems to work as you've described. Have a look at the jsFiddle I made and let me know if that's what you're after.</p> <pre><code>$(document).ready(function() { // Hook up the first divs $(".item a").click(function() { // Get the target from the name of the anchor var targetDiv = $(this).attr("name"); // Show the new div and hide the parent div $("#" + targetDiv).css("display", ""); $(this).parents("div:last").css("display", "none"); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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