Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>You can use the selector <code>$("#internalActivities tr")</code> which will select all <code>&lt;tr&gt;</code>'s, regardless of a <code>&lt;tbody&gt;</code> or not</p></li> <li><p>You need to save the current displayed index in a separate variable, or calculate the current index based on how many elements are selected (use the <code>.length</code> property)</p></li> <li><p>Check the current count of elements displayed and show/hide the corresponding buttons.</p></li> </ol> <h2>Example</h2> <h3>HTML</h3> <pre class="lang-html prettyprint-override"><code>&lt;table id="internalActivities"&gt; &lt;/table&gt; &lt;input type="button" id="seeMoreRecords" value="More"&gt; &lt;input type="button" id="seeLessRecords" value="Less"&gt; </code></pre> <h3>Javascript</h3> <pre class="lang-js prettyprint-override"><code>for (var i=0;i&lt;21;i++) { $('#internalActivities').append('&lt;tr&gt;&lt;td&gt;my data&lt;/td&gt;&lt;/tr&gt;'); } var trs = $("#internalActivities tr"); var btnMore = $("#seeMoreRecords"); var btnLess = $("#seeLessRecords"); var trsLength = trs.length; var currentIndex = 10; trs.hide(); trs.slice(0, 10).show(); checkButton(); btnMore.click(function (e) { e.preventDefault(); $("#internalActivities tr").slice(currentIndex, currentIndex + 10).show(); currentIndex += 10; checkButton(); }); btnLess.click(function (e) { e.preventDefault(); $("#internalActivities tr").slice(currentIndex - 10, currentIndex).hide(); currentIndex -= 10; checkButton(); }); function checkButton() { var currentLength = $("#internalActivities tr:visible").length; if (currentLength &gt;= trsLength) { btnMore.hide(); } else { btnMore.show(); } if (trsLength &gt; 10 &amp;&amp; currentLength &gt; 10) { btnLess.show(); } else { btnLess.hide(); } } </code></pre> <p>I created a <a href="http://jsfiddle.net/UgBcn/1/">jsFiddle demo</a> to see this in action.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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