I have divs in my code in html (they are 3 menu bars), when I click, it transforms (as if it were an animation) into an x, however, I want it when it changes and I click it function other than the first. An "openNav ()" in the first and a "closeNav ()" in the second, does anyone know a way? Using the "onClick="
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.getElementById("t").onClick="closeNav()";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
}
function myFunction(x) {
x.classList.toggle("change");
}
<div id="t" class="container1" onclick="openNav()">
<div class="container1" onclick="myFunction(this)" >
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
</div>