2
I’m having a problem with a menu.
It turns out that when the person hovers the mouse on the link Attending, happens a dropdown
, the menu appears because it is with display:none
and when it passes the mouse gets display:block
.
So far so good, only I’m having a problem, I need it to happen with more than one <ul>
. Only at 1° <ul>
is receiving this effect.
I want that when the person hovers the mouse over the link Attending, such an effect occurs in 2 or plus <ul>
'Then I’ll be able to do it like a Mega Menu
.
Code of Menu | HTML
:
<li>
<a href="blog.html">Atendimento</a>
<ul><!-- Primeiro | No caso o .first() -->
<li><a href="base.html">Base de Conhecimento</a></li>
<li><a href="blog.html">Nosso Blog</a></li>
<li><a href="contato.php">Fale conosco</a></li>
<li><a href="suporte.html">Suporte</a></li>
</ul>
<ul><!-- Segundo | Não funciona -->
<li><a href="base.html">Base de Conhecimento</a></li>
<li><a href="blog.html">Nosso Blog</a></li>
<li><a href="contato.php">Fale conosco</a></li>
<li><a href="suporte.html">Suporte</a></li>
</ul>
</li>
Code of Menu | jQuery
:
jQuery("#menu > li").hover(function() {
jQuery(this).find("ul").first().slideDown(600);
}, function() {
jQuery(this).find("ul").first().slideUp(200);
});
jQuery("#menu li ul li").hover(function() {
jQuery(this).find("ul").first().toggle(0);
});
jQuery("#menu li ul li").each(function() {
if(jQuery(this).has("ul").length > 0) {
jQuery(this).addClass("menu-arrow")
}
});
I believe the problem lies in .first()
= first (in Portuguese), in case only works with the first <ul>
, but I need it to work with both <ul>
.
Note: I tried to remove the .first()
, but he left the whole menu bugged. (I’m still a beginner)
Yeah, it’s just I didn’t put the whole code, just the 2 part
<ul>
. This code of yours has bugged my menu. It doesn’t work anymore. You also haven’t put the ex IDS:#menu li ul li
.– Alexandre Lopes
Now it worked, only an error happened, the dropdown menu also has a submenu, now it does not open more.
– Alexandre Lopes
@Alexandrelopes Examine the code carefully, note that the entire block of
<ul>
should stay inside the<li>
Dad, in this scheme that I passed works on "infinite" levels.– Jader A. Wagner
I found the problem, is that after the
<li>
has to stay the<ul>
and what I had was a<a>
, you could put the IDS? To work only in the menu. The way it works anywhere on the site.– Alexandre Lopes
what element is with id #menu?
– Jader A. Wagner
It’s not working right, because even the submenu is cascading.
– Alexandre Lopes
There would be no way only to add the effect in more than 1
<ul>
without having to touch the HTML?– Alexandre Lopes
Like the effect would also work on:
#menu > li:nth-child(4) > ul:nth-child(3)
– Alexandre Lopes
sorry I didn’t understand how is this your menu, if you can pass a fiddle with the full and original code would make it much easier
– Jader A. Wagner
Let’s go continue this discussão in chat.
– Jader A. Wagner
your jQuery seems to have a small
bug
, when I hover over the menu and then take out the mouse it gets a bug in the look of the site. Watch when you hover: http://s2.postimg.org/c5bj4m1nd/Screenshot.png. and when you hover: http://s2.postimg.org/ilkhupa6x/Screenshot2.png– Alexandre Lopes
Note: Using Google Chrome
– Alexandre Lopes
Will be if the problem is only in the Browser?
– Alexandre Lopes
Ta with way to be some bug in the rendering of the browser, because the script only makes show and hide with Hover, and if it was the script the whole object would be visible... try to change the effects of fadein to show and fadeout to Hide see if it changes anything.
– Jader A. Wagner
Yes, you did! @Jader edit your answer. It was 100% here. I wasn’t even using the fade anyway, I even put (0) in the fade to not show up. : D
– Alexandre Lopes
So maybe that was the problem (zero in the fade)...
– Jader A. Wagner
Hihihihi, I don’t know, I just know that now:
.show(0)
and.hide(0)
– Alexandre Lopes
Do I have to remove? or leave with (0) same ?
– Alexandre Lopes