I have a div that on click it expands or closes, I would also like to change the top position of a different fixed div depending on the click state of the original div.
For example
If original div is expanded I would like div 2 to have top:10px
If closed div 2 to have top:0
This is the current toggle function to expand or close the div
<a href="#" class="toggle" onclick="dropDownMSG(); this.parentNode.classList.toggle('open');return false;">
<img src="/Static/images/header-logo-top.png" alt="Informa logo"/>
</a>
then bellow I have
function dropDownMSG() {
document.getElementById("mySidenav").style.top = "10";
}
However this only adds top:10px
on click, so on toggle again that closes the div the top
dose not reset to 0
.
I need a way to say:
that if toggle open then
document.getElementById("mySidenav").style.top = "10";
Else
document.getElementById("mySidenav").style.top = "0";