JavaScript for accordion picture switch case

Source: Internet
Author: User
Tags switch case
This article is mainly to share with you the JavaScript implementation of the accordion picture switch case, I hope to help everyone, first watch the transition effect:

1. Toggle Effect:



2. JavaScript for structural logic grooming:

(function () {var con = document.getelementsbyclassname (' hm_icr_tr ') [0]; Package Layer box var Aspan = con.getelementsbyclassname (' Hmii_item_chover '); Click the Interactive box var items = con.getelementsbyclassname (' Hm_itr_item ');  Each movement of the large box var contents = con.getelementsbyclassname (' hmii_item_content ');    The text content of the Movement big box is var clickindex = 0;for (var i=0;i<aspan.length;i++) {aspan[i].index = i;        Aspan[i].onmouseover = function () {//To determine the order of points clickindex = This.index;            for (Var j=0;j<items.length;j++) {items[j].style.width = + ' px ';            contents[j].style.transition = ' 0s ';            contents[j].style.opacity = 0;        aspan[j].style.opacity = 1;        }//Box Items[this.index].style.width = + ' px ';    Current click block this.style.opacity = 0;    }}//motion End Event listener for (Var i=0;i<items.length;i++) {items[i].num = i;       Items[i].addeventlistener (' Transitionend ', function (EV) {console.log (clickindex); Contents[clickindex].style.transItion = '. 8s ';    contents[clickindex].style.opacity = ' 1 '; });} })();

3. Html,css is likely to be messy, but its core implementation is the above simple sentence JS logical statement processing completed, in my opinion the case of its programming the most important idea is to clear all, specify the current,

or specify specific element-specific behavior.

4. As a front-end small white, to be able to integrate into the IT blog communication is a very pleasant thing, I hope I can persist, continue to write down. Of course, I hope all the great God, thank you very much!

5. Since the previous blog is published on Sina Blog: Click to open the link, so after the blog content migration to CSND, the front many pictures click into will automatically jump to Sina blog! Very happy to come to CSDN, become a member of everyone!

Related Article

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.