2
I’m creating a responsive menu from scratch using html, css and jQuery. I was able to create it and it is working toggle opening and closing after function click on an image (the menu icon). The idea now is to make sure that when clicking on the menu icon, it changes to an 'x', that is to change the src, I think, indicating that there should be closed. Follow the current code:
<script>
$(document).ready(function() {
$('.icone-oppen-close').click(function() {
$('.itens-menu-mob').animate({
width: 'toggle'
}, 300);
$('.itens-menu-mob').css('display', 'block', fast);
});
});
</script>
<html>
<div class="menu-geral-mobile menu-mobile">
<div class="centralizar-menu-mob">
<div class="brand-topo-mob"><img src="img/logo-apple.png" /></div>
<div class="icone-oppen-close"><span class="glyphicon glyphicon-menu-hamburger"></span></div>
</div>
</div>
<div class="itens-menu-mob">
<ul>
<li><a href=""> Home</a></li>
<li><a href=""> Serviços</a></li>
<li><a href=""> Portifólio</a></li>
<li><a href=""> Contato</a></li>
<li><a href=""> Home</a></li>
<li><a href=""> Serviços</a></li>
<li><a href=""> Portifólio</a></li>
<li><a href=""> Contato</a></li>
</ul>
</div>
</html>
How can I do this quickly?
It worked, thanks. I have another question. The menu is working correctly, in mobile appears the toogle open and close icon and it performs the function. The problem I noticed is that when I leave the menu open and increase the width of the window using the mouse, it does not get 'display None' again. What I tried to do is to indicate that above 700px the 'toggle menu class' display will be None. But this is not due to jquery declaration, probably. I can declare in javascript even then?
– maiquel
Accept the answer then friend. https://i.stack.Imgur.com/uqJeW.png
– Laércio Lopes
You will have to monitor screen change by function
$(window).resize()
if the width($(window).width() > 700
) changes thedisplay
fornone
.– Laércio Lopes
@maiquel, accept the answers to the questions you asked in Stackoverflow as this image indicates: https://i.stack.Imgur.com/uqJeW.png
– Laércio Lopes