4
How is it possible to uncheck a checkbox if I click another field of the site?
The checkbox is used so that when the status is 'checked', it 'drags' my menu from -65% to 0 and appears on the screen, being used in a mobile responsive layout.
Unfortunately I have no idea how this can be done, but I believe it is in javascript/jquery.
Ex:
<header id="menuCelular">
<input type="checkbox" id="btn-menu">
<label id="barra-icon-menu" for="btn-menu"><label id="txt-menu" for="btn-menu">Menu</label></label>
<nav class="menuMobile">
<ul class="menu">
<li id="mapa-menu" class="abre-dropdown"><a href="\\">Mapa do site</a>
<ul class="submenu-1">
<li><a href="\\">link</a></li>
<li><a href="\\">link</a></li>
<li><a href="\\">link</a></li>
</ul>
</li>
<li class="abre-dropdown"><a href="\\">>Aprendizado</a>
<ul class="submenu-1">
<li><a href="\\">link</a></li>
<li><a href="\\">link</a></li>
<li><a href="\\">link</a></li>
</ul>
</li>
<li class="textos-menu"><a href="\\" title="\\">Textos</a></li>
<li class="fotos-menu"><a href="\\" title="\\"></label>Fotos</a></li>
</ul>
</nav>
</header>
Now, when the menu is open, if I click #menuCellular bar it does not close unless I press outside the . menuMobile region
Tried the method
$.blur
of jquery, I think adding it to the checkbox and assigning a function works– Jhonatan Simões
Can you give an example? I never used the method.
– Cobra
Probably the checkbox is not the best solution in this case. It would be better something related to the focus, or even links to fragment (
#
) + css.– Bacco
Yes, I imagined it. It turns out it was the first responsive menu I did, so I got a little confused about all this, it’s new to me. I will edit and leave the site for you to look at. If you visit, resize your browser to see the mobile version (479px).
– Cobra
@Thiagobarros the hidden checkbox is very interesting for things with behavior toggle (on/off), but it’s just that in your case, it would be more related to the same focus. But it’s good to know how to use css + check, you can do some more complex things.
– Bacco
Yes, I learned the method with some video lessons from youtube. Anyway. it is not possible to make the following structure: Imagine that the checkbox has been marked, then: If the user presses in some region outside the menu that was opened with the own checkbox, it is unchecked, and automatically the menu disappears, because it only opens if the checkbox is marked.
– Cobra