Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you were willing to use jQuery, the selector of your interest is something along the lines of</p> <pre><code>$('div#parent-container &gt; div').filter(':visible'); </code></pre> <p>For example, if I were to demonstrate with next &amp; previous, I would do it <a href="http://jsfiddle.net/DSKVR/shgfT/" rel="nofollow">something like this</a>. With targeted links it would work by appending ID's to the <code>divs</code> and referencing those in the <code>href</code> attribute of `anchors'. (now included within example)</p> <hr> <p>Something to <a href="http://jsfiddle.net/DSKVR/shgfT/" rel="nofollow">mess with</a>:</p> <pre><code>$(function(){ //Reference Object var $divs = $('div &gt; div'); //Buffer for selected variable var $selected = 0; //Show first $divs.eq(0).show(); $('#next').click(function(){ //Update selected var $selected = $divs.filter(':visible'); //Save next to variable var $next = $selected.next(); //Change Visibility toggle($next); //Prevent Default return false; }); $('#prev').click(function(){ $selected = $divs.filter(':visible'); var $prev = $selected.prev(); toggle($prev); return false; }); $('a').click(function(){ $selected = $divs.filter(':visible'); var selector = $(this).attr('href'); if(selector == '#') return false; toggle( $( selector ) ); return false; }); var toggle = function($toggle){ if(!$toggle.length) return false; $selected.hide(); $toggle.show(); } }); </code></pre> <hr> <pre><code>&lt;!--Simple Implementation and dependancies--&gt; &lt;a id="prev" href="#"&gt;Prev&lt;/a&gt; &lt;a id="next" href="#"&gt;Next&lt;/a&gt; &lt;a href="#item-4"&gt;Show Item Four&lt;/a&gt; &lt;div&gt; &lt;div id="item-1"&gt;One&lt;/div&gt; &lt;div id="item-2"&gt;Two&lt;/div&gt; &lt;div id="item-3"&gt;Three&lt;/div&gt; &lt;div id="item-4"&gt;Four&lt;/div&gt; &lt;div id="item-5"&gt;Five&lt;/div &lt;div id="item-6"&gt;Six&lt;/div&gt; &lt;/div&gt; </code></pre> <hr> <pre><code>div &gt; div { font-size:5em; width:auto; text-align:center; padding:20px 0; display:none; } </code></pre>
 

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