Rss Feed Like Us on facebook Google Plus

June 19, 2014

Accordion with Jquery Toggle

Accordion Displays Collapsible Content on very less space. I am going to give a demo of  accordion using JQuery Toggle.

You can achieve this also by using bootstrap. to see an advance version you can checkout CSS Tricks Website.


DEMO


Lorem Ipsum 1+
Lorem Ipsum 2+
Lorem Ipsum 3+

Code

<html>
<head>
<style>
.accordion_container {
    width: 500px;
}
.accordion_head
{
    background: linear-gradient(0deg, #F79711, #DC7E03) repeat scroll 0 0 #D07906;
    color: white;
    cursor: pointer;
    font-family: segoe ui;
    font-size: 15px;
    margin: 0 0 1px 0;
    padding: 7px 11px;
    font-weight: bold;
    background-color: #D07906;
}
 
.accordion_body h3
{
    background-color: #CCCCCC;
    font-size: 20px;
    font-variant: small-caps;
    margin: 0;
    padding: 5px;
}
.accordion_body a.anchorButton
{
    font-size: 14px;
    padding: 2px 15px;
    float: right;
    width: auto;
    height: auto;
}
.accordion_body
{
    background: #f1f1f1;
}
.accordion_body p
{
    padding: 8px;
    margin: 0px;
}
.plusminus
{
    float: right;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    //toggle the componenet with class accordion_body
    $(".accordion_head").click(function(){
        if ($('.accordion_body').is(':visible')) {
            $(".accordion_body").slideUp(600);
            $(".plusminus").text('+');
        }
        $(this).next(".accordion_body").slideDown(600);
        $(this).children(".plusminus").text('-');
    });
});
</script>
</head>
    <div class="accordion_container">
        <div class="accordion_head">Lorem Ipsum 1<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 1 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
            </div>
        <div class="accordion_head">Lorem Ipsum 2<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 2 .It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
            </div>
        <div class="accordion_head">Lorem Ipsum 3<span class="plusminus">+</span></div>
            <div class="accordion_body" style="display: none;">
            <p>Lorem Ipsum 3 is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.   </p>
            </div>
 
    </div>
</html>


© 2011-2016 Techimpulsion All Rights Reserved.


The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.