Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close all open panels when another one is clicked
    primarykey
    data
    text
    <p>I've got a search box running here:</p> <p><a href="http://codepen.io/h0rhay/pen/Kgqwt" rel="nofollow">http://codepen.io/h0rhay/pen/Kgqwt</a></p> <p>Code:</p> <pre><code>$('.findNavL1').click(function () { $(this).children('.slideContainer').toggleClass('show').css('z-index', +1); }); $('.slideContainer').click(function () { if ($(this).hasClass('show')) { $(this).toggleClass('show'); } }); </code></pre> <p>Markup:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="twelve columns width33"&gt; &lt;div class="navContainer rel"&gt; &lt;h2 class="navHeading"&gt;Find a holiday&lt;/h2&gt; &lt;ul class="findHolNav"&gt; &lt;li class="findNavL1" onClick="return true"&gt; &lt;span&gt;When&lt;/span&gt; &lt;div class="slideContainer"&gt; &lt;h2 class="internalContent"&gt;This is some content 1&lt;/h2&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="findNavL1" onClick="return true"&gt; &lt;span&gt;How many Days &lt;/span&gt; &lt;div class="slideContainer"&gt; &lt;h2 class="internalContent"&gt;This is some content 2&lt;/h2&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="findNavL1" onClick="return true"&gt; &lt;span&gt;Where&lt;/span&gt; &lt;div class="slideContainer"&gt; &lt;h2 class="internalContent"&gt;This is some content 3&lt;/h2&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="findNavL1" onClick="return true"&gt; &lt;span&gt;Departing&lt;/span&gt; &lt;div class="slideContainer"&gt; &lt;h2 class="internalContent"&gt;This is some content 4&lt;/h2&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="findNavL1" onClick="return true"&gt; &lt;span&gt;No. of People&lt;/span&gt; &lt;div class="slideContainer"&gt; &lt;h2 class="internalContent"&gt;This is some content 5&lt;/h2&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.rel { position:relative; } .staticP { position:static !important; } .show { display:block !important; } .hide { display:none; } /* ----------------------------------------- Shared Styles ----------------------------------------- */ .width33 { width:33.3% !important; } .navContainer { background:#ccc; } .findHolNav { list-style-type: none; padding:0; } .findNavL1{ cursor:pointer; } .findNavL1 span { padding:20px; display:block; } .findNavL1:nth-of-type(odd){ background-color:#c6c6c6; } .findNavL1:hover{ background-color:#c2c2c2; } .findNavL1:hover &gt; .slideContainer, .findNavL1:active &gt; .slideContainer { } .slideContainer { display:none; background-color:lime; min-height:100%; position:absolute; top:0; left:100%; width:208%; } </code></pre> <p>At the moment, the UI is nearly right. When you click on a link the corresponding panel opens up.</p> <p>However if you click on another link, its corresponding panel opens but the previous one stays open.</p> <p>I want it to close.</p> <p>Which would leave only the active one open.</p> <p>//////////////////////////////////////</p> <p>I should have said.. The UI is a bit more complex than maybe I said before.</p> <p>1st click: Slides open the container.</p> <p>Click same link: Slides shut</p> <p>Click inside open container: Container remains open.</p> <p>(I've got all this working ok)</p> <p>If you click different link, then open container shuts and new one opens..</p> <p>Thats the bit I'm stuck on.</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