Super simple accordion effect making

Source: Internet
Author: User
Tags jquery library

The end result of the accordion is as follows:

To achieve the above effect is very simple, no plug-in

Step.1

HTML Structure creation

<DivID= "Firstpane"class= "Menu_list">         <Pclass= "Menu_head">Header-1</P>        <Divclass= "Menu_body">        <ahref="#">Link-1</a>         <ahref="#">Link-2</a>         <ahref="#">Link-3</a>            </Div>        <Pclass= "Menu_head">Header-2</P>        <Divclass= "Menu_body">            <ahref="#">Link-1</a>         <ahref="#">Link-2</a>         <ahref="#">Link-3</a>            </Div>        <Pclass= "Menu_head">Header-3</P>        <Divclass= "Menu_body">          <ahref="#">Link-1</a>         <ahref="#">Link-2</a>         <ahref="#">Link-3</a>                   </Div>  </Div> 

First look at the results:

Step.2

To add a style to the above HTML, the default is to see only the header of each group, the content in each group is hidden by default.

. Menu_list{width:150px;}. Menu_head{padding:5px 10px;cursor:Pointer;position:relative;margin:1px;Font-weight:Bold;background:#eef4d3 URL (left.png) center right no-repeat;}. Menu_body{Display:None;}. Menu_body a{Display:Block;Color:#006699;Background-color:#EFEFEF;Padding-left:10px;Font-weight:Bold;text-decoration:None;}. Menu_body a:hover{Color:#000000;text-decoration:Underline; }

Step.3

Based on the jquery library, write JS to make the list move.

The requirement should be that when we click on the header, the body underneath her should be displayed, and the other menu groups will be closed.

$ ("#firstpane p.menu_head"). Click (function()    {        $ (this). css ({backgroundimage: "URL (down.png)"}). Next ("Div.menu_body"). Slidetoggle ("Div.menu_body"). Slideup (           "slow"). $ (this). Siblings (). css ({backgroundimage: "url (left.png)});    });

At this point, the Accordion effect menu is complete!

Super simple accordion effect making

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.