I have the following menu, which works when the screen is width: 768px or smaller. When I click on fa-bars , it disappears and shows fa-times . Opening the menu. So far so good. I want when I click on fa-bars it will hide the menu again and show fa-bars .
$('header nav div.menuMobile').click(function(event) {
event.preventDefault();
$('header nav div.menuMobile ul').show(300);
$('.fa-bars').hide(300);
$('.fa-times').show(300);
});
$('.fa-times').click(function(event) {
event.preventDefault();
$('header nav div.menuMobile ul').show(300);
$('.fa-times').hide(300);
$('.fa-bars').show(300);
});
header nav ul,
header nav a img {
display: none
}
.menuMobile {
display: block
}
.menuMobileClose {
display: block
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><header><nav><divclass="menuMobile">
<i class="fa fa-bars" aria-hidden="true"></i>
<i style="display:none" class="fa fa-times" aria-hidden="true"></i>
<img src="assets/images/layout/logo.png">
<ul>
<li>
<a href="link">Home</a>
</li>
<li>
<a href="link">Quem Somos</a>
</li>
<li>
<a href="link">Contato</a>
</li>
<li>
<a href="link">E-commerce</a>
<div class="submenu">
<ul>
<li>
<a href="">Plataformas E-commerce</a>
</li>
<li>
<a href="">Lojas virtuais customizadas</a>
</li>
<li>
<a href="">Solução virtual para venda</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
</header>