Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you can make one of them visible by default, you can skim eeeeeverything down to these lines:</p> <pre><code>$(document).ready(function () { $(".infoexpanderHead1, .infoexpanderHead2").click(function () { $(".infoexpanderContent1,.infoexpanderContent2").slideToggle(); $(".infoexpanderSign1, .infoexpanerSign2").each(function() { $(this).html($(this).html() == '-' ? '+' : '-'); }); }); }); </code></pre> <p><a href="http://jsfiddle.net/YqEVZ/3/" rel="nofollow">jsfiddle</a></p> <p>Now, what I see is a bit faulty in your code is that you use classes that are uncommon between 2 "grouped" sets of elements. You can make this much more dynamic if you update your layout like so:</p> <pre><code>&lt;div class="infoExpander expanded"&gt; &lt;div class="head"&gt;&lt;span class="sign"&gt;-&lt;/span&gt;Lorem ipsum&lt;/div&gt; &lt;div class="content"&gt;Lorem ipsum&lt;br /&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; &lt;div class="infoExpander"&gt; &lt;div class="head"&gt;&lt;span class="sign"&gt;+&lt;/span&gt;Lorem ipsum&lt;/div&gt; &lt;div class="content"&gt;Lorem ipsum&lt;br /&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; </code></pre> <p>And your JS like so:</p> <pre><code>$(document).ready(function () { $(".infoExpander .head").click(function () { $('.content').not($(this).nextAll('.content')).slideUp().prevAll('.head').find('.sign').html('+'); $(this).nextAll('.content').slideDown(function() { $(this).closest('.infoExpander').addClass('expanded').find('.sign').html('-'); }); }); }); </code></pre> <p>Here's a <a href="http://jsfiddle.net/YqEVZ/5/" rel="nofollow">jsfiddle</a> to see it in action.</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.
    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