Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery dropdown menu hover state
    primarykey
    data
    text
    <p>My problem is:</p> <p>I have a drop down menu and i want that when I hover the menu the text color change and when I hover the submenu the hover state stays for both. I use this code:</p> <pre><code>$("ul li").hover(function () { $(this).stop().animate({ backgroundColor: "white"}, 500); }, function () { $(this).stop().animate({ backgroundColor: "black"}, 400); }); } </code></pre> <p>to animate the background-color on hover in menu and submenu.</p> <p>I want to change the color of the text on hover to (diferent for menu and submenu, not the same color animation). For this I use this code:(Submenu example, for menu example, change the selector to $('ul.menu li a')</p> <pre><code>$('ul.submenu li a').hover(function () { $(this).css({color:'#FFFFFF'}); }, function () { $(this).css({color:'#00FF00'}); }); </code></pre> <p>All This works fine, but when I hover the submenu the menu returns to the original color state (because the mouseleave is activated on menu hover out).</p> <p>All I want is that when I hover submenu the hover state in menu stays active as well.</p> <p>I've tried many things but all give me problems, only thing that works is css, but I need to control the text colors dinamically too.</p> <p><strong>CSS That Works:</strong></p> <pre><code>ul li:hover a { color: #FFF; } </code></pre> <p>(with this css code I control the menu color with the css and when I hovered the submenu the menu stays in active state, but the submenu works with jquery .hover).</p> <p>Can anyone Help? Thanks!</p> <p><strong>HTML Menu:</strong></p> <pre><code>&lt;ul class="menu"&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt; &lt;ul class="submenu"&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;text&lt;/a&gt; &lt;/ul&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload