Home Web Front-end JS Tutorial Summary of Tab sliding tabs and image switching (various effects) implemented by jQuery_jquery

Summary of Tab sliding tabs and image switching (various effects) implemented by jQuery_jquery

May 16, 2016 pm 03:39 PM
jquery tab switch picture slide Tab

The example in this article describes the Tab sliding tab and image switching effect implemented by jQuery. Share it with everyone for your reference. The details are as follows:

Here is a summary of several Tabs, sliding doors, tabs, and picture switching. Many commonly used effects are implemented in one web page. Everyone's favorite sliding doors, focus picture switching, label tabs, and text rotation are all concentrated in one page. Together, I made boring contributions and couldn’t take care of writing when I was busy. In addition, I also added rounded corners, which were all written with reference to the knowledge I learned before. During this period, the jquery-1.6.2.min.js framework library was used.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/jquery-n-tab-cha-pic-codes/

The specific code is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tab</title>
<style>
html body  {margin:0px; padding:0px;}
.t_body{border:1px solid #ddd; padding:10px; width:250px; margin:50px;float:left;}
.aa {background-color:#eee; width:25px; cursor:pointer; float:left; margin-left:10px; text-align:center;}
.bb {background-color:#eae; width:250px; height:250px; display:none; font-size:50px;}
.cc {background-color:#eee; width:100%; height:20px; display:none;}
.on {background-color:#c21; width:30px; border-bottom:0px; border-top:0px;}
.yuan1 span {display: block;overflow: hidden;height: 1px; border-color:#77a;} 
.yuan2 span {display: block;overflow: hidden;height: 1px; border-color:#77a;} 
.span1 {margin:0px 3px; background-color:#77a;}
.span2 {margin:0px 1px; border-left:2px solid; border-right:2px solid;}
.span3 {margin:0px 1px; border-left:1px solid; border-right:1px solid;}
.d_body {margin:50px;width:400px; height:400px; font-size:12px;float:left;}
.d_top {height:40px; border-left:1px solid #77a; border-right:1px solid #77a;}
.d_t {float:left; margin-top:7px; margin-left:10px; border:1px solid #77a; width:100px; height:31px; line-height:31px; background-color:#eee;}
.d_t a {color:#555; text-decoration:none;}
.d_t a:hover {color:#933; text-decoration:underline; font-weight:bold; }
.d_main {border:1px solid #77a; border-top:0px; height:300px;}
.ln  {position:relative; border-bottom:1px solid #77a; top:40px; z-index:-1;}
.bbb  {background-color:#fff; height:100%; display:none; margin:10px;}
.on1 {border-bottom:1px solid #fff; background-color:#fff;}
.fl  {float:left;}
.clr {clear:both;}
.of  {overflow:hidden;}
.textcenter{text-align:center;vertical-align:middle;}
</style>
<script src="jquery-1.6.2.min.js"></script>
<script>
$(document).ready(function() {
 /*
  o1: 标签元素
  o2: 内容元素
  c : 标签元素显示用样式
  e : 触发事件 如 click mouseover 
 */
 function tab1(o1,o2,c,e){
  o1.each(function(i){
   $(this).bind(e,function(){
    o2.hide().eq(i).show();
    o1.removeClass(c);
    $(this).addClass(c);
   })
   if ($(this).hasClass(c)) {
    $(this).addClass(c);
    o2.hide().eq(i).show();
   }
  })
 }
 /*
  o1: 标签元素
  o2: 内容元素
  c : 标签元素显示用样式
  t1: 标签切换时间
  t2: 内容渐进时间
  a : 内容渐进起始半透明度 0.1~1
  b : 内容渐进结束半透明度 0.1~1
 */
 function tab2(o1,o2,c,t1,t2,a,b){
  var count=o1.size()-1;
  var now;
  var TimeInterval;
  o1.each(function(i){
   $(this).mouseover(function(){
    o2.hide().eq(i).show();
    o1.removeClass(c);
    $(this).addClass(c);
    window.clearInterval(TimeInterval);
   }).mouseout(function(){
    now = i+1;
    TimeInterval = window.setInterval(changeimage,t1);
   });
   //初始化显示
   if ($(this).hasClass(c)) {
    $(this).addClass(c);
    o2.hide().eq(i).show();
    now = i+1;
   }
  })
  TimeInterval = window.setInterval(changeimage,t1);
  function changeimage(){
   if(now>count)now=0;
   o2.hide().eq(now).stop().fadeTo(0,a).fadeTo(t2,b);
   o1.removeClass(c).eq(now).addClass(c);
   now++;
  }
 }
 /*
  o1: 标签元素
  o2: 内容元素
  o3: 内容元素
  c : 标签元素显示用样式
  e : 触发事件 如 click mouseover 
 */
 function tab3(o1,o2,o3,c,e){
  o1.each(function(i){
   $(this).bind(e,function(){
    o2.hide().eq(i).show();
    o3.hide().eq(i).show();
    o1.removeClass(c);
    $(this).addClass(c);
   })
   if ($(this).hasClass(c)) {
    $(this).addClass(c);
    o2.hide().eq(i).show();
    o3.hide().eq(i).show();
   }
  })
 }
 /*
  o1: 标签元素
  o2: 内容元素
  o3: 内容元素
  c : 标签元素显示用样式
  t1: 标签切换时间
  t2: 内容渐进时间
  a : 内容渐进起始半透明度 0.1~1
  b : 内容渐进结束半透明度 0.1~1
 */
 function tab4(o1,o2,o3,c,t1,t2,a,b){
  var count=o1.size()-1;
  var now;
  var TimeInterval;
  o1.each(function(i){
   $(this).mouseover(function(){
    o2.hide().eq(i).show();
    o3.hide().eq(i).show();
    o1.removeClass(c);
    $(this).addClass(c);
    window.clearInterval(TimeInterval);
   }).mouseout(function(){
    now = i+1;
    TimeInterval = window.setInterval(changeimage,t1);
   });
   //初始化显示
   if ($(this).hasClass(c)) {
    $(this).addClass(c);
    o2.hide().eq(i).show();
    o3.hide().eq(i).show();
    now = i+1;
   }
  })
  TimeInterval = window.setInterval(changeimage,t1);
  function changeimage(){
   if(now>count)now=0;
   o3.hide().eq(now).show();
   o2.hide().eq(now).stop().fadeTo(0,a).fadeTo(t2,b);
   o1.removeClass(c).eq(now).addClass(c);
   now++;
  }
 }
 //调用函数
 tab1($(".yuan1 .d_t"),$(".yuan1 .bbb"),"on1","mouseover");
 tab1($(".yuan2 .d_t"),$(".yuan2 .bbb"),"on1","click");
 tab1($(".d0 .aa"),$(".d0 .bb"),"on","click");
 tab1($(".d1 .aa"),$(".d1 .bb"),"on","mouseover");
 tab2($(".d2 .aa"),$(".d2 .bb"),"on",1500,800,0.1,1);
 tab3($(".d3 .aa"),$(".d3 .bb"),$(".d3 .cc"),"on","mouseover");
 tab4($(".d4 .aa"),$(".d4 .bb"),$(".d4 .cc"),"on",1500,800,0.1,1);
 tab4($(".d5 .aa"),$(".d5 .bb"),$(".d5 .cc"),"on",1500,0,1,1);
});
</script>
</head>
<body>
<div class="d_body yuan1">
 <div>鼠标悬浮切换</div><br>
 <span class="span1"></span><span class="span2"></span><span class="span3"></span>
 <div class="d_top">
  <div class="ln"></div>
  <div class="d_t textcenter on1">
   <a href="javascript:">第一个标签</a>
  </div>
  <div class="d_t textcenter">
   <a href="javascript:">第二个标签</a>
  </div>
  <div class="d_t textcenter">
   <a href="javascript:">第三个标签</a>
  </div>
 </div>
 <div class="d_main clr of">
  <div class="bbb"><font color="blue">第一个内容</font></div>
  <div class="bbb"><font color="red">第二个内容</font></div>
  <div class="bbb"><font color="black">第三个内容</font></div>
 </div>
 <div class="clr of"></div>
</div>
<div class="d_body yuan2">
 <div>点击切换</div><br>
 <span class="span1"></span><span class="span2"></span><span class="span3"></span>
 <div class="d_top">
  <div class="ln"></div>
  <div class="d_t textcenter on1">
   <a href="javascript:">第一个标签</a>
  </div>
  <div class="d_t textcenter">
   <a href="javascript:">第二个标签</a>
  </div>
  <div class="d_t textcenter">
   <a href="javascript:">第三个标签</a>
  </div>
 </div>
 <div class="d_main clr of">
  <div class="bb"><font color="blue">第一个内容</font></div>
  <div class="bb"><font color="red">第二个内容</font></div>
  <div class="bb"><font color="black">第三个内容</font></div>
 </div>
 <div class="clr of"></div>
</div>
<div class="t_body d0">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">点击切换</div>
 <div class="bb">4</div>
 <div class="bb">5</div> 
<div style="clear:both;"></div>
</div>
<div class="t_body d1">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">3</div>
 <div class="bb">4</div>
 <div class="bb">5</div> 
<div style="clear:both;"></div>
</div>
<div class="t_body d2">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">3</div>
 <div class="bb">4</div>
 <div class="bb">5</div> 
<div style="clear:both;"></div>
</div>
<div class="t_body d3">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">悬浮切换</div>
 <div class="bb">4</div>
 <div class="bb">5</div>
 <div class="cc">111111</div>
 <div class="cc">222222</div>
 <div class="cc">333333</div>
 <div class="cc">444444</div>
 <div class="cc">555555</div> 
<div style="clear:both;"></div>
</div>
<div class="t_body d4">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">3</div>
 <div class="bb">4</div>
 <div class="bb">5</div>
 <div class="cc">111111</div>
 <div class="cc">222222</div>
 <div class="cc">333333</div>
 <div class="cc">444444</div>
 <div class="cc">555555</div> 
<div style="clear:both;"></div>
</div>
<div class="t_body d5">
 <div class="aa">a</div>
 <div class="aa">b</div>
 <div class="aa on">c</div>
 <div class="aa">d</div>
 <div class="aa">e</div><br>
 <div class="bb">1</div>
 <div class="bb">2</div>
 <div class="bb">3</div>
 <div class="bb">4</div>
 <div class="bb">5</div>
 <div class="cc">111111</div>
 <div class="cc">222222</div>
 <div class="cc">333333</div>
 <div class="cc">444444</div>
 <div class="cc">555555</div> 
<div style="clear:both;"></div>
</div>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s jQuery programming.

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the &quot;My&quot; button in the lower right corner; (2) On the personal center page, find &quot;Settings&quot; and click it; (3) Scroll down and find the &quot;Clear Cache&quot; option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? Mar 21, 2024 pm 09:12 PM

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the &quot;Comment&quot; button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a &quot;picture&quot; button or a &quot;+&quot; button, click

6 Ways to Make Pictures Sharper on iPhone 6 Ways to Make Pictures Sharper on iPhone Mar 04, 2024 pm 06:25 PM

Apple's recent iPhones capture memories with crisp detail, saturation and brightness. But sometimes, you may encounter some issues that may cause the image to look less clear. While autofocus on iPhone cameras has come a long way, allowing you to take photos quickly, the camera can mistakenly focus on the wrong subject in certain situations, making the photo blurry in unwanted areas. If your photos on your iPhone look out of focus or lack sharpness overall, the following post should help you make them sharper. How to Make Pictures Clearer on iPhone [6 Methods] You can try using the native Photos app to clean up your photos. If you want more features and options

How to make ppt pictures appear one by one How to make ppt pictures appear one by one Mar 25, 2024 pm 04:00 PM

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

What should I do if the images on the webpage cannot be loaded? 6 solutions What should I do if the images on the webpage cannot be loaded? 6 solutions Mar 15, 2024 am 10:30 AM

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

How to convert pdf documents into jpg images with Foxit PDF Reader - How to convert pdf documents into jpg images with Foxit PDF Reader How to convert pdf documents into jpg images with Foxit PDF Reader - How to convert pdf documents into jpg images with Foxit PDF Reader Mar 04, 2024 pm 05:49 PM

Are you also using Foxit PDF Reader software? So do you know how Foxit PDF Reader converts pdf documents into jpg images? The following article brings you how Foxit PDF Reader converts pdf documents into jpg images. For those who are interested in the method of converting jpg images, please come and take a look below. First start Foxit PDF Reader, then find "Features" on the top toolbar, and then select the "PDF to Others" function. Next, open a web page called "Foxit PDF Online Conversion". Click the "Login" button on the upper right side of the page to log in, and then turn on the "PDF to Image" function. Then click the upload button and add the pdf file you want to convert into an image. After adding it, click "Start Conversion"

How to arrange two pictures side by side in wps document How to arrange two pictures side by side in wps document Mar 20, 2024 pm 04:00 PM

When using WPS office software, we found that not only one form is used, tables and pictures can be added to the text, pictures can also be added to the table, etc. These are all used together to make the content of the entire document look richer. , if you need to insert two pictures into the document and they need to be arranged side by side. Our next course can solve this problem: how to place two pictures side by side in a wps document. 1. First, you need to open the WPS software and find the picture you want to adjust. Left-click the picture and a menu bar will pop up, select &quot;Page Layout&quot;. 2. Select &quot;Tight wrapping&quot; in text wrapping. 3. After all the pictures you need are confirmed to be set to &quot;Tight text wrapping&quot;, you can drag the pictures to the appropriate position and click on the first picture.

Operation tutorial for switching from win11 home version to professional version_Operation tutorial for switching from win11 home version to professional version Operation tutorial for switching from win11 home version to professional version_Operation tutorial for switching from win11 home version to professional version Mar 20, 2024 pm 01:58 PM

How to convert Win11 Home Edition to Win11 Professional Edition? In Win11 system, it is divided into Home Edition, Professional Edition, Enterprise Edition, etc., and most Win11 notebooks are pre-installed with Win11 Home Edition system. Today, the editor will show you the steps to switch from win11 home version to professional version! 1. First, right-click on this computer on the win11 desktop and properties. 2. Click Change Product Key or Upgrade Windows. 3. Then click Change Product Key after entering. 4. Enter the activation key: 8G7XN-V7YWC-W8RPC-V73KB-YWRDB and select Next. 5. Then it will prompt success, so you can upgrade win11 home version to win11 professional version.

See all articles