I need to know what is the mistake on this js code, I need that the click expand the div and at the second click the div come back to the original dimension This is the javascript:
<script> function myBurger() {
document.getElementById("burger").classList.toggle('expand');
}
</script>
the relative html is this:
<div class="container" onclick="myBurger()">
<input id="click" name="exit" type="checkbox" />
<label for="click"><span class="burger"></span>
</div>
<div id="burger" > prova</div>
and this is the css:
#burger{
height: 10px;
width: 10px;
background-color: #fff;
top: 10%;
left: 10%;
position: absolute;
transition: height 2s ease, width 2s ease;
}
#burger.expand{
height: 200px;
width: 200px;
}
The complete code is there: www.figmentasergio.altervista.org
labeltagtoggleis a method ofclassListdeveloper.mozilla.org/en-US/docs/Web/API/Element.classList