TAB tab delay Toggle Effect JS Implementation

Source: Internet
Author: User

Try.html

<! DOCTYPE html>

 Try.css

*{margin:0;    padding:0;    List-style:none; font-size:12px;}.    notice{width:298px;    height:98px;    margin:10px;    border:1px solid #eee; Overflow:hidden;}.    notice-tit{height:27px;    position:relative; Background-color: #f7f7f7;}.    Notice-tit ul{Position:absolute;    width:301px; Left: -1px;}.    Notice-tit ul li{Float:left;    width:58px;    height:26px;    Text-align:center;    line-height:26px;    Overflow:hidden;    padding:0 1px;    Background: #f7f7f7; border-bottom:1px solid #eee;}.    Notice-tit ul li.select{background: #fff;    Border-bottom-color: #fff;    border-left:1px solid #eee;    border-right:1px solid #eee;    padding:0; Font-weight:bolder;}.    Notice Li A:link,.notice-tit li a:visited{text-decoration:none; Color: #000;}. Notice Li a:hover{color: #f90;}. Notice-con. mod{margin:10px 10px 10px 19px;}.    Notice-con. mod ul li{float:left;    width:134px;    height:25px; Overflow:hidden;}

Try.js

function $ (ID) {return typeof id=== ' string '? document.getElementById (ID): ID;}    Window.onload = function () {var index=0;    var timer=null;    Get the mouse slide over or click on the label and the element to toggle content var titles = $ (' notice-tit '). getElementsByTagName (' Li ');    var divs =$ (' Notice-con '). getElementsByTagName (' div ');    alert (divs.length);    if (titles.length!=divs.length) return;        for (Var i=0;i<titles.length;i++) {titles[i].id=i;            Titles[i].onmouseover=function () {//Use this variable to refer to the currently sliding Li var that=this;                If there is a timer ready to execute, clear immediately, only if the current dwell time is greater than 500ms to start the execution if (timer) {cleartimeout (timer);            Timer=null;                    }//Delay half-second execution timer=window.settimeout (function () {for (Var j=0;j<titles.length;j++) {                    Titles[j].classname= ";                Divs[j].style.display= ' None ';                } titles[that.id].classname= ' select '; Divs[that.id].style.display= ' block ';        },500); }    }}

 Effect:

2017-09-05 20:32:11

TAB tab delay Toggle Effect JS Implementation

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.