My goal is to display a list everytime the button is pressed kind of like a dropdown list, so I made a sort of test html,css and js files and somehow it doesn't work, the log function in my js code outputs the word 'year' on the console but the class list toggle doesn't seem to change/add the "active" on the divs' class.
Below is my js.
function btnFunction(identifier){
console.log(identifier)
var element = document.getElementById(identifier);
element.classList.toggle("active");}
Below is my html.
<div class="modal-content-col-6-drop">
<button onclick="btnFunction('year')" class="drop-btn">sample</button>
</div>
<div id="year" class="select">
<ul>
<li>0 Year</li>
<li>1 Year</li>
</ul>
</div>
Below is my css.
#year{
display: none;
}
.active{
display: block;
}