Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This example uses no jQuery just because there is no jQuery-tag in topic. (Edit, misunderstood)</p> <p><strong>HTML</strong></p> <pre><code>&lt;a href="" id="plus"&gt;+&lt;/a&gt;&lt;a href="" id="minus"&gt;-&lt;/a&gt; &lt;div class="plusable" style="display: block;"&gt;Stuff1&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff2&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff3&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff4&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff5&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff6&lt;/div&gt; &lt;div class="plusable" style="display: none;"&gt;Stuff7&lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>window.onload = function () { var plusButton = document.getElementById('plus'); var minusButton = document.getElementById('minus'); var plusables = document.getElementsByClassName('plusable'); var current = 0; function hideCurrent () { plusables[current].style.display = 'none'; } function showCurrent () { plusables[current].style.display = 'block'; } plusButton.onclick = function () { if (current === plusables.length - 1) { return false; } hideCurrent(); current += 1; showCurrent(); return false; }; minusButton.onclick = function () { if (current === 0) { return false; } hideCurrent(); current -= 1; showCurrent(); return false; }; }; </code></pre> <p><a href="http://jsfiddle.net/VYk39/1/" rel="nofollow">Example fiddle</a></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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