var countPage; var nowPag = 1; var pageSize; var countSize;
var starIndex; var endIndex;
// User submitted information var name; var sex; var age;
// Define line number var num = 1;
$( document).ready(function() { // Register the event of adding a user $("#submit").click(function() { // Get the information submitted by the user name = $("#name").val(); sex = $("input[name='sex']:checked").val(); age = $("#age") .val(); pageSize = $("#selectSize option:selected").val(); // alert(name sex age pageSize);
}); // Register the operation of selecting the number of displayed items $("#selectSize").change(function() { pageSize = $("#selectSize option:selected").val(); pageNation(); });
// Function for paging operation var pageNation = function() { // Get the number of all data items countSize = $("#show tr").size(); // Get the total number of pages countPage = Math.ceil(countSize / pageSize);
// Handle page turning operation if (this.nodeType == 1) { var idValue = $(this).attr("id "); if ("first" == idValue) { // alert(idValue); nowPag = 1; } else if ("back" == idValue) { // alert(nowPag); if (nowPag > 1) { nowPag--; }
} // alert(pageSize); // Get the start and end index of the display starIndex = ( nowPag - 1) * pageSize 1; endIndex = nowPag * pageSize;
if (endIndex > countSize) { // alert("The index is greater than the total number of records" endIndex); endIndex = countSize; }
if (countSize < pageSize) { // alert("The total number of records is less than the number of displayed items per page" endIndex); endIndex = countSize; }
// Hidden operations $("#show tr:lt(" (starIndex - 1) ")").hide (); $("#show tr:gt(" (endIndex - 1) ")").hide(); } // Change the bottom display operation $("# sizeInfo") .html( "Currently from the " starIndex " record to the " endIndex " record, a total of " countSize " records."); $("#pageInfo") .html("The current page is " nowPag ", total " countPage "pages."); };
[html] view plaincopy View the code piece on CODE derived to mine Code piece
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn