Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple jQuery content Slider
    primarykey
    data
    text
    <p>I have an unordered list that holds 'x' amount of list items. These list items will be shown but only 'n' amount will be visible at a time. I then want to add a next and previous thus sliding the previous content out and the new 'n' amount of list items in.</p> <p>However what I have does the job as a paginator but well as a content slider.</p> <p><a href="http://jsfiddle.net/5QLM6/8/%5d" rel="nofollow">jsFiddle</a></p> <p>HTML</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span class="box"&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a href="" id="prev"&gt;Prev&lt;/a&gt; &lt;a href="" id="next"&gt;Next&lt;/a&gt; </code></pre> <p>CSS</p> <pre><code>body { margin: 5px; } ul { overflow: hidden; } li { float: left; } .box { width: 100px; height: 100px; background: #33cccc; margin: 5px; display: block; } </code></pre> <p>JS</p> <pre><code>var from = 0, step = 3; // show show next function function showNext(list) { list .find('li').hide().end() .find('li:lt(' + (from + step) + '):not(li:lt(' + from + '))') .show(); from += step; } // show previous function function showPrevious(list) { from -= step; list .find('li').hide().end() .find('li:lt(' + from + '):not(li:lt(' + (from - step) + '))') .show(); } // show initial set showNext($('ul')); // clicking on the 'more' link: $('#more').click(function(e) { e.preventDefault(); showNext($('ul')); }); // clicking on the 'prev' link: $('#prev').click(function(e) { e.preventDefault(); showPrevious($('ul')); }); </code></pre>
    singulars
    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.
 

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