Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - How to show/hide multiple DIVs with child DIVs
    primarykey
    data
    text
    <p>I've got a markup as follows (code modified from <a href="http://jsfiddle.net/nick_craver/srg6g/" rel="nofollow">http://jsfiddle.net/nick_craver/srg6g/</a>):</p> <pre><code>&lt;div id="maps"&gt; &lt;div class="map-box"&gt;&lt;h2&gt;London &amp;amp; South East&lt;/h2&gt;&lt;a href="#london"&gt;&lt;img src="http://dummyimage.com/100x100/000/fff&amp;text=London" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="map-box"&gt;&lt;h2&gt;South West, Ireland and Wales&lt;/h2&gt;&lt;a href="#south-west"&gt;&lt;img src="http://dummyimage.com/100x100/000/fff&amp;text=South+West" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="map-box"&gt;&lt;h2&gt;South Central &amp;amp; Home Counties&lt;/h2&gt;&lt;a href="#south-central"&gt;&lt;img src="http://dummyimage.com/100x100/000/fff&amp;text=South+Central" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="map-box"&gt;&lt;h2&gt;North England, Northern Ireland &amp;amp; Scotland&lt;/h2&gt;&lt;a href="#north"&gt;&lt;img src="http://dummyimage.com/100x100/000/fff&amp;text=North" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="map-box"&gt;&lt;h2&gt;Midlands&lt;/h2&gt;&lt;a href="#midlands"&gt;&lt;img src="http://dummyimage.com/100x100/000/fff&amp;text=Midlands" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;br /&gt;&lt;br/&gt; &lt;div id="areas"&gt; &lt;div id="london"&gt; &lt;div&gt;content london 1&lt;/div&gt; &lt;div&gt;content london 2&lt;/div&gt; &lt;/div&gt; &lt;div id="south-west"&gt; &lt;div&gt;content south west 1&lt;/div&gt; &lt;div&gt;content south west 2&lt;/div&gt; &lt;/div&gt; &lt;div id="south-central"&gt; &lt;div&gt;content south central 1&lt;/div&gt; &lt;div&gt;content south central 2&lt;/div&gt; &lt;/div&gt; &lt;div id="north"&gt; &lt;div&gt;content north 1&lt;/div&gt; &lt;div&gt;content north 2&lt;/div&gt; &lt;/div&gt; &lt;div id="midlands"&gt; &lt;div&gt;content midlands 1&lt;/div&gt; &lt;div&gt;content midlands 2&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And my JavaScript code looks like as follows:</p> <pre><code>$(".map-box a").click(function(e) { $("#areas div").hide(); $(this.hash).show(); e.preventDefault(); }); $("#areas div").not("#london, #london div").hide(); </code></pre> <p>When a user clicks on a image, I'd like to hide what's currently displayed and show both contents associated for that image but this doesn't work.</p> <p>e.g.,</p> <ul> <li>User clicks on "South West"</li> <li>Display both "content south west 1" and "content south west 2"</li> </ul> <p>Would anybody be able to tell me what I'm doing wrong?</p>
    singulars
    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. 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