jquery tab Toggle + Timer

Source: Internet
Author: User

For the focus of the carousel, the first choice is to write with JS, a lot of reasons are said to be because of the timer ah, get traversal ah various reasons

The following I wrote the focus of the Carousel diagram, with the JQ of the Tabe switch added a timer ~

How the JQ code:

var banner_box=$ (". Banner_box li"),//Get pictures of Li
buttons=$ (". Img_tit li"),//Get button Li
Inow=0,//Traversal initial value is 0
timer=null;//Timer
Butsl=buttons.length; Number of buttons

Buttons.mouseover (function () {
Clearinterval (timer);//mouse-in button cancel timer
Inow =$ (This). index ();
$ (this). AddClass ("active"). Siblings (). Removeclass ("active");//mouse swipe button to add active
Banner_box.eq (Inow). Show (). siblings (). hide ();//Click the button to traverse the corresponding picture display
});

Mouse move Out button, execute timer
Buttons.mouseout (function () {
Show ();
});

Put the timer in a function.
Function Show () {
Timer= setinterval (function () {
inow++;

if (INOW>BUTSL) {
inow=0;
}
Banner_box.eq (Inow). Show (). siblings (). Hide ();
Buttons.eq (Inow). addclass ("active"). Siblings (). Removeclass ("active");
},1000);
};

Show ();

});

CSS code:

<div class= "Conwind" >
<div class= "Banner_box" >
<ul>
<li style= "Display:block;" ><a href= "#" ></a></li>
<li><a href= "#" >11111111111111</a></li>
<li><a href= "#" >2222222222222222</a></li>
<li><a href= "#" >3333333333333333</a></li>
<li><a href= "#" >4444444444444</li>
</ul>
</div>
<div class= "Img_tit conwind" id= "buttons" >
<ul>
<li class= "Active" index= "1" > Zwilling pan 4-piece set </li>
<li index= "2" > Zwilling pan 4-piece set </li>
<li index= "3" > Zwilling pan 4-piece set </li>
<li index= "4" > Zwilling pan 4-piece set </li>
<li index= "5" > Zwilling pan 4-piece set </li>
</ul>
</div>
</div>

jquery tab Toggle + Timer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.