Last active
June 19, 2020 12:33
-
-
Save rahuladams/58c4be260d55d31eb813c3a8109a3768 to your computer and use it in GitHub Desktop.
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
var accordion_items = document.querySelectorAll('.accordion-item'); | |
if (accordion_items != null) { | |
var i = 0; | |
accordion_items.forEach(function (e) { | |
i++; | |
e.addEventListener('click', function () { | |
e.querySelector('.accordion-content').classList.toggle('active'); | |
}); | |
}) | |
} | |
//HTML | |
<div class="accordion-item"> | |
<div class="accordion-heading medium-b-pad">HEADING</div> | |
<div class="accordion-content">CONTET_TO_REVEAL</div> | |
</div> | |
//SCSS | |
.accordion{ | |
&-item{ | |
margin-bottom: 30px; | |
border-bottom: 1px solid #000; | |
} | |
&-heading{ | |
cursor: pointer; | |
&:hover{ | |
opacity: .8; | |
} | |
} | |
&-content{ | |
display: none; | |
&.active{ | |
display: block; | |
padding-bottom: 30px; | |
} | |
} | |
h6{ | |
margin-bottom: 20px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment