I wrote a toggle burger menu. I want to tell this code to hide <div class="line1"></div> and <div class="line3"></div> when the .menu is clicked.
How can I do this?
$(function(){
$('.menu').click(function(){
$('.sidebar').toggle();
});
});
.menu {
background:#ddd;
padding:15px;
width:fit-content;
height:fit-content;
position:relative;
}
.menu > div {
background-color:black;
width:22px;
height:1px;
}
.line1 {
top:12px;
position:absolute;
}
.line2 {
top:16px;
}
.line3 {
top:22px;
}
.sidebar {
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="menu">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
<div class="sidebar">
Sidebar
</div>