Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery pager not working on last page
    text
    copied!<p>My pager works except for the last page that you click on. So if my last page is 11 that has been clicked the pager stops working when going backwards. If you click a page and then click another it works fine except for the last page. here it is on <a href="http://jsfiddle.net/37sfE/4/" rel="nofollow">jsFiddle</a> (its been updated and working now</p> <p>Javascript:</p> <pre><code>$(document).ready(function () { var pageIndex = 1; function pagerControl(pageIndex, pageCount, step) { var result = ""; if (pageCount &gt; 1) { var startPoint = Math.floor((pageIndex / step)) * step; if ((pageIndex % step) == 0) { startPoint -= step; } if (pageIndex &lt; pageCount) { result += '&lt;a href="#" rel="' + (pageIndex + 1) + '"&gt;Next&lt;/a&gt;'; } else { result += '&lt;span&gt;Next&lt;span&gt;'; } //alert(startPoint); for (var i = startPoint + 1; i &lt;= pageCount &amp;&amp; i &lt;= (startPoint + step + 1); i++) { if (i != pageIndex) { result += '&lt;a href="#" rel="' + i + '"&gt;' + i + '&lt;/a&gt;'; } else { result += '&lt;span&gt;' + i + '&lt;/span&gt;'; } } if (pageIndex &gt; 1) { result += '&lt;a href="#" rel="' + (pageIndex - 1) + '"&gt;Prev&lt;/a&gt;'; } else { result += '&lt;span&gt;Prev&lt;/span&gt;'; } } $('#pager').html(result); $('#pager &gt; a').click(function (e) { reload($(e.target).attr('rel')); e.preventDefault(); }); } function reload(page) { pagerControl(page, 11, 4); } pagerControl(1, 11, 4); }); </code></pre> <p><a href="http://jsfiddle.net/37sfE/4/" rel="nofollow">jsFiddle</a></p>
 

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