Write the folding panel by yourself

Source: Internet
Author: User

This is a function in the project. When you start to add this function, you first think of the jquery plug-in. Because there are many jquery folding menu plug-ins, there are many folding panel plug-ins, so the first is to test the jquery plug-in, however, after testing about three items, we found that the function was indeed powerful, but there were several items that did not meet our requirements, or the color was hard to change (using a fixed image ), or you need to change more CSS styles. So I decided to develop it myself.

Developing the folding panel with jquery is very simple.

Implementation ideas:
Hide all by default. When you click a button, perform the hide operation first, and then display the currently clicked button. If you click again, perform the hide operation.

Code:
1. Reference

<script src="http://shandongit.com/js/jquery.js"></script>

2. CSS

Body {font-family: ;}. box-show {width: 350px; margin: 1em. 5em ;}. box-show H3 {margin: 0; padding :. 45em; Background: # ebebeb; color: black; font-size: 16px; border-top: 1px solid # 3c3c3c; border-bottom: 1px solid # 3c3c3c ;}. box-show Div {padding :. 5em. 25em ;}

3. html

<Div class = "Box-show"> 

4. js used

$(document).ready(function() {  $(‘div.box-show:eq(0)> div‘).hide();    $(‘div.box-show:eq(0)> h3‘).click(function() {    $(this).next().slideToggle(‘fast‘);  });});

Demo address:
Collapse panel demo

This article from "Weifang SEO" blog, please be sure to keep this source http://weifangseo.blog.51cto.com/9257185/1543283

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.