


Detailed explanation of how JavaScript implements Taobao product advertising effects
This article mainly introduces in detail the effect of Taobao product advertising based on JavaScript. It has certain reference value. Interested friends can refer to it.
The example in this article shares with everyone the implementation of Taobao using JavaScript. The specific code for the product advertising effect is for your reference. The specific content is as follows
CSS part:
##
ul{ margin: 0; padding: 0; } li{ list-style: none; } #ad{ width: 298px; height: 208px; border: 1px #ff6300 solid; padding: 4px 1px; text-align: center; } #ad .listL{ float: left; } #ad .listR{ float: right; } #ad li{ width: 48px; height: 26px; border: 1px #ffadad solid; background: #fff7f7; color: #333; line-height: 26px; margin-bottom: 2px; cursor: pointer; } #ad img{ height: 206px; width: 188px; background: url(images/loader_ico.gif) no-repeat center center; } #ad .cur{ background: #ff8494; color: #fff }
<p id="ad"> <ul class="listL"> <!-- <li class="cur"></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> --> </ul> <a href="#"><img src="" alt=""></a> <ul class="listR"> <!-- <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> --> </ul> </p>
window.onload = function(){ var op = document.getElementById('ad'); var aUl = op.getElementsByTagName('ul'); var oImg = op.getElementsByTagName('img')[0]; var aImg = ['images/pic1.jpg','images/pic2.jpg','images/pic3.jpg','images/pic4.jpg','images/pic5.png','images/pic6.png','images/pic7.png','images/pic8.png','images/pic1.jpg','images/pic2.jpg','images/pic3.jpg','images/pic4.jpg','images/pic5.png','images/pic6.png']; var aTxt = ['连衣裙','T恤','雪纺','铅笔裤','婚纱','外套','连体裤','包包','凉鞋','单鞋','太阳镜','丝袜','帆布鞋','情侣鞋']; var len = aImg.length; var oldNum = 0; var num = 0; var timer = null; var speed = 1; // 创建添加左右两侧li for( var i = 0; i < len/2; i++){ aUl[0].innerHTML += '<li>'+ aTxt[i] +'</li>' aUl[1].innerHTML += '<li>'+ aTxt[i + len/2] +'</li>' } var aLiL = aUl[0].getElementsByTagName('li'); var aLiR = aUl[1].getElementsByTagName('li'); var arrLi = []; // 将遍历的所有li添加到数组arrLi中 for( var i = 0; i < aLiL.length; i++){ arrLi.push(aLiL[i]); } for( var i = 0; i < aLiR.length; i++){ arrLi.push(aLiR[i]); } // console.log(arrLi.length); // 函数初始化 function init(n){ oImg.src = aImg[n]; arrLi[oldNum].className = ''; arrLi[n].className = 'cur'; oldNum = n; } init(0); // 鼠标经过li,图片切换 for(var i = 0; i < len; i++){ arrLi[i].index = i; arrLi[i].onmouseover = function(){ init(this.index); } }; // 定时切换 function fnTimer(n){ timer = setInterval(function(){ // type1:顺序切换 /* n ++; if(n == len){ n = 0; }*/ // type2:倒序切换 if(n == len-1){ speed = -1; }else if(n== 0){ speed = 1; } n += speed; init(n); },1000); }; fnTimer(0); // 鼠标移入,清除定时器 op.onmouseover = function(){ clearInterval(timer); }; // 鼠标移出,开启定时器 op.onmouseout = function(){ fnTimer(oldNum); }; };
The above is the detailed content of Detailed explanation of how JavaScript implements Taobao product advertising effects. 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 turn off the ads recommended by 360 Browser? I believe that many users are using 360 Browser, but this browser sometimes pops up advertisements, which makes many users very distressed. Let this site carefully introduce to users how to Turn off the ads recommended by 360 Browser on your computer. How to turn off the ads recommended by 360 Browser on your computer? Method 1: 1. Open 360 Safe Browser. 2. Find the "three horizontal bars" logo in the upper right corner and click [Settings]. 3. Find [Lab] in the taskbar on the left side of the pop-up interface, and check [Enable "360 Hotspot Information" function]. Method 2: 1. First double-click

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Users will encounter a lot of advertisements when browsing Moments, so how can they completely turn off the advertisements? Users need to click Settings in My, then find Personal Information and Permissions, then click Personalized Ads Management, and just turn off ad personalization. This article will tell you how to completely turn off ads in Moments, so take a look! WeChat usage tutorial: How to completely turn off ads in Moments? Answer: It cannot be turned off completely. You can only turn off personalized recommendations. Specific methods: 1. First, click on me, and then find the settings inside. 2. Find the personal information and permissions options. 3. Click on the personalized advertising management function inside. 4. Click the switch on the right side of ad personalization and turn it off. How to turn off ads: 1. Find the ads in Moments. 2. Click right

After updating the Edge browser, many users found that there were a lot of advertisements on the interface. For example, at the bottom of the new tab page, there were links to multiple websites and the word advertisements were marked, which looked very annoying. Is there any way to turn off personalized ads in Edge browser? The editor has searched many methods on the Internet, and I will share with you a little trick to turn off ads. How to turn off ads in the new version of Edge? 1. Open the Edge browser. 2. Click [•••] in the upper right corner. 3. Click [Settings]. 4. Click [Privacy, Search and Services]. 5. Turn off the switch on the right side of "Personalize your web experience" to turn off the personalization pushed by Microsoft.

When we usually use Douyin for entertainment, we often have some inexplicable and strange advertisements that disturb our leisure experience. Many users are not disturbed by them and want to turn off the recommendation push of these advertisements, but they don't. If you know how to operate it, then the editor of this website will bring you this tutorial guide and this detailed introduction, hoping to help everyone in need. First, we first find the option to understand and manage ad push in the app settings, then see all the ad-related switch options below, click the switch at the back to turn it off, and then a confirmation prompt to turn off the ad will pop up, we click to confirm. Close ads

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.
