


How to use jQuery to achieve seamless carousel and left and right clicks
This time I will show you how to use jQuery to achieve seamless carousel and left and right clicks, and how to use jQuery to achieve seamless carousel and left and right clicks. What are the precautions? The following is a practical case, let’s take a look. take a look.
There are many, many seamless carousel left and right loops that we want in the web page. This is my first carousel effect, and it is also the most basic. I would like to share it with you. For beginners, I hope you can To learn from it, I want you to abuse me and give me your valuable opinions. This is the effect I want<p id="djlb"> <p id="bigul"> <ul> <li> <img src="../images/djlb1.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> <ul> <li> <img src="../images/djlb2.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> <ul> <li> <img src="../images/djlb3.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> <ul> <li> <img src="../images/djlb2.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> <ul> <li> <img src="../images/djlb2.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> <ul> <li> <img src="../images/djlb2.gif" alt=""> <p class="zt4">赵茜</p> <p class="zt22">北京大学历史系研究生</p> </li> <li> <img src="../images/yc2.gif" alt="yc2"> </li> </ul> </p> </p> <p id="aniu"> <p id="bleft"></p> <p id="bright"></p> </p> </p>
#djlb { width: 1200px; height: 600px; overflow: hidden; } #bigul { width: 1800px; height: 560px; } #bigul > ul { position: relative; width: 300px; height: 560px; float: left; } #bigul > ul > li:nth-child(even) { position: absolute; display: none; } #bigul > ul > li { width: 300px; height: 560px; float: left; } #aniu { position: relative; } #aniu > p { position: absolute; } #aniu > p:first-child{ left:-55px; top: -290px; display: inline-block; border-left: 6px solid #c2c2c2; border-top: 6px solid #c2c2c2; width: 37px; height: 37px; transform: rotate(-45deg); } #aniu > p:last-child{ left: 1210px; top: -290px; display: inline-block; border-right: 6px solid #c2c2c2; border-bottom: 6px solid #c2c2c2; width: 37px; height: 37px; transform: rotate(-45deg); } #aniu > p:first-child:hover{ border-left: 6px solid #ffcc00; border-top: 6px solid #ffcc00; } #aniu > p:last-child:hover { border-right: 6px solid #ffcc00; border-bottom: 6px solid #ffcc00; }
$(function () { var i = 0, tick, list, ul = $("#bigul"); $("#bright").click(function () { $("#bigul").animate({ "margin-left": -300 }, 30000, function () {//当你执行完了后发生的事件 list =ul.find("ul"); //正常的话ul就是li,因为我这个需要鼠标浮动显示隐藏,结构一样 ul.append(list.first()); //ul追加到最后一个 ul.css("margin-left",0); //在每一次点击过后,margin-left初始化为零,为什么嘛要初始化呢? 思考一下? });//这样就向右无限循环了,就像队列一样 if (tick) { clearTimeout(tick); } //清除上一次定时器 tick = setTimeout(function () { $("#bright").click(); }, 30000); 定时器自动的部分 }); $("#bleft").click(function(){ list = ul.find("ul"); list.last().insertBefore(list.first()); // 当第一次点击时,把最后的搬到前面来, ul.css("margin-left",-300); ul.animate({ "margin-left": 0 }, 3000); //同样这个问题?? if (tick) { clearTimeout(tick); } tick = setTimeout(function () { $("#bleft").click(); }, 3000); }); $("#bright").click(); //自动向右事件 });
The whole idea:
Use animate to move li, When you click to the right, use the append() method Add the first card to the last card, and clear it every time you move it. When you click to the left, use insertBefore() to insert the last picture into the first picture, and also clear ittick is the timer settimeout we definedThe last sentence It is an automatic right event. Mouse movement, display and hiding are all done using mouseout() and show(), hide().I believe you have mastered the method after reading the case in this article. For more exciting content, please pay attention to other related articles on the php Chinese website! Recommended reading:How to use async function in js
##How to optimize js async functionThe above is the detailed content of How to use jQuery to achieve seamless carousel and left and right clicks. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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 implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

In today's software development field, Golang (Go language), as an efficient, concise and highly concurrency programming language, is increasingly favored by developers. Its rich standard library and efficient concurrency features make it a high-profile choice in the field of game development. This article will explore how to use Golang for game development and demonstrate its powerful possibilities through specific code examples. 1. Golang’s advantages in game development. As a statically typed language, Golang is used in building large-scale game systems.

PHP Game Requirements Implementation Guide With the popularity and development of the Internet, the web game market is becoming more and more popular. Many developers hope to use the PHP language to develop their own web games, and implementing game requirements is a key step. This article will introduce how to use PHP language to implement common game requirements and provide specific code examples. 1. Create game characters In web games, game characters are a very important element. We need to define the attributes of the game character, such as name, level, experience value, etc., and provide methods to operate these

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:

I'm really sorry that I can't provide real-time programming guidance, but I can provide you with a code example to give you a better understanding of how to use PHP to implement SaaS. The following is an article within 1,500 words, titled "Using PHP to implement SaaS: A comprehensive analysis." In today's information age, SaaS (Software as a Service) has become the mainstream way for enterprises and individuals to use software. It provides a more flexible and convenient way to access software. With SaaS, users don’t need to be on-premises
