Eu estou usando essa função pra quando um ícone for clicado o menu desaparecer.
let sidebar = document.querySelector('.sidebar-page')
let sidebar_toggle = document.querySelector('.sidebar-toggle-box')
sidebar_toggle.addEventListener('click', function(){
sidebar.style.display = 'none'
sidebar_toggle.addEventListener('click', function(){
sidebar.style.display = 'grid'
})
})
quando eu clico pela segunda vez ele volta, mas se eu clicar de novo depois o display não fica 'none'. Como faz pra corrigir isso?
html:
<body>
<section class="all-page-content">
<header>
<div class="sidebar-toggle-box">
<i class="fas fa-bars"></i>
</div>
<div class="medium-column-header">
<div class="search">
<input type="search" name="search" value="" placeholder="Pesquisar"/>
<button type="button" name="button"><i class="fas fa-search"></i></button>
</div>
</div>
<div class="black-row"></div>
</header>
<aside class="sidebar-page">
<nav>
<ul>
<li><a href="#"> <div class=""><i class="fas fa-cogs"></i><p>loremsd</p></div></a></li>
<li><a href="#"> <div class=""><i class="fab fa-btc"></i><p>lorisd</p></div> </a></li>
<li><a href="#"> <div class=""><i class="fas fa-bell"></i><p>losari</p></div> </a></li>
<li><a href="#"> <div class=""><i class="fas fa-chart-line"></i><p>loresa</p></div> </a></li>
</ul>
</nav>
</aside>
<aside class="right-sidebar">
<address class="">
<ul>
<li><a href="#"><i class="fab fa-instagram"></i></a></li>
<li><a href="#"><i class="fab fa-twitch"></i></a></li>
<li><a href="#"><i class="fab fa-youtube"></i></a></li>
<li><a href="#"><i class="fab fa-whatsapp"></i></a></li>
</ul>
</address>
</aside>
<section class="content">
<article class="">
<div class="tittle">
<h6>Lorem ipsum dolor sit amet, est laborum.</h6>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<aside class="">
<h6>Author: Giovani Lopes</h6>
<data value="24/11/2022">24/11/1996</data>
</aside>
</article>
<article class="">
<div class="tittle">
<h6>sunt in culpa qui officia deserunt mollit anim id est laborum.</h6>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</article>
</section>
<footer>
<div class="">
<p>Copyright (c) 2018 Copyright Holder All Rights Reserved.</p>
</div>
</footer>
</section>
<script type="text/javascript" src="js/teste.js" ></script>
</body>