0
Today I have an onclick in id #menu
, every time I click on #menu
he makes certain action, I need to create an action that everything is not #menu
, do certain action. How do I do this? There is a: !ação
in javascript?
My JS code is this:
$(document).ready(function() {
$("#head header .menu").on('click', function() {
if ($(this).hasClass('active')) {
$('#menus').css({
"top": "-120px"
});
$('#menus').css({
"left": "-50%"
});
$(this).removeClass('active')
} else {
$('#menus').css({
"top": "0"
});
$('#menus').css({
"left": "0"
});
$(this).addClass('active')
}
});
});
And the HTML:
<icon class="menu"></icon>
<ul>
<div id="menus">
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
<li><a href="#">LINK</a></li>
</ul>
</div>
I can put here the code I have for my menu, and you adapt this solution to my code?
– Tiago P.C
@Tiagop. C yes, put the question.
– Sergio
I added my JS in the question, already think it is enough.
– Tiago P.C
@Tiagop. C and HTML?
– Sergio
ready! @Die
– Tiago P.C
@Tiagop. C it’s hard to guess code... please add what’s missing here: https://jsfiddle.net/hkafq36d/ I’m not sure if that’s enough to do the rest yourself.
– Sergio
This is exactly how it is in jsfiddle.
– Tiago P.C
@Tiagop. C ok, I added HTML to what you had in question. Is that what you wanted then? -> https://jsfiddle.net/hkafq36d/1/ I got rid of jQuery and put the positions in the CSS.
– Sergio
Exactly, @Rgio, thank you very much!
– Tiago P.C