Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have answered a similar question in the past <a href="https://stackoverflow.com/a/8747305/297641">https://stackoverflow.com/a/8747305/297641</a></p> <p>So I edited that code a little to work with what you have,</p> <p><a href="http://jsfiddle.net/skram/QScXU/20/" rel="nofollow noreferrer"><strong>DEMO</strong></a></p> <p><strong>HTML:</strong></p> <pre><code>&lt;div class="prev"&gt;Previous&lt;/div&gt; &lt;div class="nav-wrapper clearfix"&gt; &lt;div&gt;Car&lt;/div&gt; &lt;div&gt;Boat&lt;/div&gt; &lt;div&gt;Truck&lt;/div&gt; &lt;div&gt;Van&lt;/div&gt; &lt;div&gt;Bi-Cycle&lt;/div&gt; &lt;div&gt;Omni&lt;/div&gt; &lt;div&gt;Race Car&lt;/div&gt; &lt;/div&gt; &lt;div class="next"&gt;Next&lt;/div&gt; </code></pre> <p><strong>JS:</strong></p> <pre><code>var stPt = 0, elToShow = 5; //showing 5 elements var $nav_wrapper = $('.nav-wrapper'); var $list = $nav_wrapper.find('div'); //get the list of div's var $copy_list = []; var copy_lgt = $list.length - elToShow; //call to set thumbnails based on what is set initNav(); function initNav() { var tmp; for (var i = elToShow; i &lt; $list.length; i++) { tmp = $list.eq(i); $copy_list.push(tmp.clone()); tmp.remove(); } } $('.next').click (function () { $list = $nav_wrapper.find('div'); //get the list of div's //move the 1st element clone to the last position in copy_list $copy_list.splice(copy_lgt, 0, $list.eq(0).clone() ); //array.splice(index,howmany,element1,.....,elementX) //kill the 1st element in the div $list.eq(0).remove(); //add to the last $nav_wrapper.append($copy_list.shift()); }); $('.prev').click (function () { $list = $nav_wrapper.find('div'); //get the list of li's //move the 1st element clone to the last position in copy_li $copy_list.splice(0, 0, $list.eq(elToShow-1).clone()); //array.splice(index,howmany,element1,.....,elementX) //kill the 1st element in the UL $list.eq(elToShow-1).remove(); //add to the last $nav_wrapper.prepend($copy_list.pop()); }); </code></pre>
    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.
 

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