Hi i tried a accordion in wordpress home page which works when a button is clicked some content to show below with css and javasrcipt, but to me its not working. Here is the CSS
button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
}
button.accordion.active, button.accordion:hover {
background-color: #ddd;
}
div.panel {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: 0.6s ease-in-out;
opacity: 0;
}
div.panel.show {
opacity: 1;
max-height: 500px;
}
Here is the js
<script type="text/javascript">
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function ( ) {
this.classList.toggle("active");
this.nextElementSibling.classList.toggle("show");
};
};
</script>
I tried to include the js in the header.php but not working while all the css are working fine Thanks.