jQuery list pagination code with search jump function
This is a very practical jQuery paging code that can set the number of multiple lists and has a paging search jump function.
js code
<script> var page = 1; var limit = 10; var sumPage = 6; var size = 28; $(function(){ page = parseInt(page); limit = parseInt(limit); //防止页码出现字符串,转换类型 loadClass(); setPageMsg(); initPage(); $("#pageLt").find("a").unbind("click").click(function(){ $("#pageLt").find("a").removeClass("active"); $(this).addClass("active"); limit = parseInt($(this).text()); // 分页执行的fun }); }); function loadClass(){ if(limit == 10){ $("#pageLt").find("a").removeClass("active"); $("#pageLt").find("a").eq(0).addClass("active"); }else if(limit == 20){ $("#pageLt").find("a").removeClass("active"); $("#pageLt").find("a").eq(1).addClass("active"); }else if(limit == 30){ $("#pageLt").find("a").removeClass("active"); $("#pageLt").find("a").eq(2).addClass("active"); }else if(limit == 40){ $("#pageLt").find("a").removeClass("active"); $("#pageLt").find("a").eq(3).addClass("active"); } } /** 初始化分页控件 **/ function initPage(){ $(".down_page").click(function(){ //上一页 if(page != 1){ page = page - 1; $("#nowPage").text(page); // 分页执行的fun }else{ alert("已经是第一页了","warning"); } }); $(".up_page").click(function(){ //下一页 if(page < parseInt(sumPage)){ page = page + 1; $("#nowPage").text(page); // 分页执行的fun }else{ alert("已经是最后一页了","warning"); } }); $(".jump_page").click(function(){ var pageNum = $("#pageNum").val(); if(parseInt(pageNum) <= parseInt(sumPage)){ page = parseInt(pageNum); $("#nowPage").text(page); // 分页执行的fun }else{ alert("页数不能大于总页数","warning"); } }); } function setPageMsg(){ $("#count").text(size); $("#nowPage").text(page); $("#allPage").text(""+sumPage+"页"); } </script>
Jquery is one of the important technologies required for web programming. Jquery is another excellent Javascrīpt framework after prototype. It is a lightweight js library that is compatible with CSS3 and various browsers. jQuery enables users to more easily process HTML documents and events, implement animation effects, and easily provide AJAX interaction for websites. Another big advantage of jQuery is that its documentation is very complete and its various applications are explained in detail. There are also many mature plug-ins to choose from. jQuery can keep the code and HTML content of the user's HTML page separated. That is to say, there is no need to insert a bunch of js in the HTML to call the command. You only need to define the id.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
24 Jun 2016
CSS3 JQUERY page scrolling effects code
24 Jun 2016
58 jQuery simulated CSS3 transition page switching effects
06 Jul 2016
jquery waterfall flow LightBox picture box special effects
03 Dec 2024
jQuery $(document).ready and UpdatePanels: A Refined LookWhen utilizing jQuery to apply mouseover effects to elements within an UpdatePanel, the...
13 Nov 2024
jQuery: Dynamically Modifying Text with Mouseover EventsWhen interacting with elements on a web page, adding subtle effects can enhance user...
22 Oct 2024
To replicate hover effects on touch-enabled devices, this article proposes a technique using a combination of CSS and JavaScript. It demonstrates how to add hover effects to elements on touchstart and touchend events using jQuery, and how to style th
24 Jun 2016
CSS3 input box shadow effects and other shadow effects
24 Jun 2016
61 web page special effects that are very fashionable and have great visual effects
23 Oct 2024
jQuery doesn't natively fade background images. This article presents a workaround using hidden tags with absolute positioning and negative z-index to mimic background behavior, allowing for fading effects on background images.
Hot Tools
jQuery2019 Valentine's Day Confession Fireworks Animation Special Effects
A very popular jQuery Valentine's Day confession fireworks animation special effect on Douyin, suitable for programmers and technical geeks to express their love to the girl they love. No matter you choose to be willing or not, you have to agree in the end.
layui responsive animated login interface template
layui responsive animated login interface template
520 Valentine's Day confession web animation special effects
jQuery Valentine's Day Confession Animation, 520 Confession Background Animation
Cool system login page
Cool system login page
HTML5 tape music player-CASSETTE PLAYER
HTML5 tape music player-CASSETTE PLAYER