


How to implement jQuery imitating Tencent video list paging effect_jquery
The example in this article describes how jQuery can achieve the paging effect of Tencent video list. Share it with everyone for your reference. The details are as follows:
JQuery is used here to imitate the paging effect of Tencent video list, without refreshing the paging effect. Click the paging button to enter the next page content list without refreshing.
The screenshot of the running effect is as follows:
The specific code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>仿腾讯视频列表分页效果</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <style type="text/css"> .main{width:800px;zoom:1;margin:0 auto;} .item{width:800px;overflow:hidden;} ul{padding:0;width:860px;zoom:1;} .clear{zoom:1;} .clear:after{content:"";display:block;height:0;clear:both;visibility:hidden;} ul li{list-style-type:none;float:left;background:#F69;font-size:60px;text-shadow:1px 1px 3px #555;width:380px;height:200px;margin:10px 40px 10px 0;line-height:200px;text-align:center;color:#fff;} .page_btn{padding-top:20px;} .page_btn a{cursor:pointer;padding:5px;border:solid 1px #ccc;font-size:12px;} .page_box{float:right;} .num{padding:0 10px;} </style> <script src="jquery-1.7.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $("ul li:gt(3)").hide();//初始化,前面4条数据显示,其他的数据隐藏 var total_q=$("ul li").index()+1;//总数据 var current_page=4;//每页显示的数据 var current_num=1;//当前页数 var total_page= Math.round(total_q/current_page); //总页数 var next=$(".next");//下一页 var prev=$(".prev");//上一页 $(".total").text(total_page);//显示总页数 $(".current_page").text(current_num);//当前的页数 //下一页 $(".next").click(function(){ if(current_num==7){ return false;//如果大于总页数就禁用下一页 }else{ $(".current_page").text(++current_num);//点击下一页的时候当前页数的值就加1 $.each($('ul li'),function(index,item){ var start = current_page* (current_num-1);//起始范围 var end = current_page * current_num;//结束范围 if(index >= start && index < end){//如果索引值是在start和end之间的元素就显示,否则就隐 $(this).show(); }else{ $(this).hide(); } }); } }); //上一页方法 $(".prev").click(function(){ if(current_num==1){ return false; }else{ $(".current_page").text(--current_num); $.each($('ul li'),function(index,item){ var start = current_page* (current_num-1);//起始范围 var end = current_page * current_num;//结束范围 if(index >= start && index < end){//如果索引值是在start和end之间的元素就显示,否则就隐藏 $(this).show(); }else { $(this).hide(); } }); } }) }) </script> </head> <body> <div class="main"> <div class="item"> <ul class="clear"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> <li>11</li> <li>12</li> <li>13</li> <li>14</li> <li>15</li> <li>16</li> <li>17</li> <li>18</li> <li>19</li> <li>20</li> <li>21</li> <li>22</li> <li>23</li> <li>24</li> <li>25</li> <li>26</li> <li>27</li> <li>28</li> </ul> </div> <div class="page_btn clear"> <span class="page_box"> <a class="prev">上一页</a><span class="num"><span class="current_page">1</span><span style="padding:0 3px;">/</span><span class="total"></span></span><a class="next">下一页</a> </span> </div> </div> </body> </html>
I hope this article will be helpful to everyone’s jquery programming design.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

There are two most common ways to paginate PHP arrays: using the array_slice() function: calculate the number of elements to skip, and then extract the specified range of elements. Use built-in iterators: implement the Iterator interface, and the rewind(), key(), current(), next(), and valid() methods are used to traverse elements within the specified range.

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

jQuery is a popular JavaScript library widely used in web development. During web development, it is often necessary to dynamically add new rows to tables through JavaScript. This article will introduce how to use jQuery to add new rows to a table, and provide specific code examples. First, we need to introduce the jQuery library into the HTML page. The jQuery library can be introduced in the tag through the following code:
