Created
August 12, 2019 06:11
-
-
Save frontend-coder/91dc9cee45d4c9532c18a70bf155fd81 to your computer and use it in GitHub Desktop.
Simple Jquery Accordion #accordion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('.acc-btn').click(function() { | |
$('.acc-content').slideUp('normal'); | |
$('.acc-btn').removeClass('acc-active'); | |
if ($(this).next().is(':visible') == true) { | |
$('.acc-btn').removeClass('active'); | |
} | |
if ($(this).next().is(':hidden') == true) { | |
$(this).next().slideDown('normal'); | |
$(this).addClass('acc-active'); | |
} | |
$('.acc-content').one().removeClass('show'); | |
}); | |
$('.acc-content').hide(); | |
$('.show').show(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div class="acc-btn">Button 1</div> | |
<div class="acc-content"> | |
Content 1 | |
</div> | |
</div> | |
<div> | |
<div class="acc-btn">Button 2</div> | |
<div class="acc-content show"> | |
Content 2 | |
</div> | |
</div> | |
<div> | |
<div class="acc-btn">Button 3</div> | |
<div class="acc-content"> | |
Content 3 | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.acc-btn { | |
display: block; | |
position: relative; | |
margin-bottom: -2px; | |
border-radius: 0; | |
color: #fff !important; | |
background: #FF9000; | |
border: 1px solid #Fff; | |
padding: 10px 15px; | |
border-bottom: 1px solid transparent; | |
font-size: 18px; | |
color: inherit; | |
cursor: pointer; | |
} | |
.acc-content { | |
padding: 15px; | |
} | |
.acc-btn:before { | |
position: absolute; | |
top: 50%; | |
right: 15px; | |
font-size: 18px; | |
z-index: 9999; | |
margin-top: -13px; | |
font-family: FontAwesome; | |
content: "\f078"; | |
color: #fff; | |
} | |
.acc-active:before { | |
font-family: FontAwesome; | |
content: "\f077"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment