[英]JQuery hover fadeIn/fadeOut on different divs
I have lists inside a div called header which I want to expand the lists on hover over each list, but I want all the lists which have been hovered over to stay open until the mouse is moved out of the header div. 我在名为header的div中有一个列表,我想在将鼠标悬停在每个列表上时扩展列表,但我希望所有悬停的列表保持打开状态,直到将鼠标移出header div。 So far I have fadeIn/fadeOut for each list individually or I can get each list to fadeIn and stay open but not fadeOut whenever I move out of the div.
到目前为止,我已经为每个列表单独设置了fadIn / fadeOut,或者我可以让每个列表都进行fadeIn并保持打开状态,但是每当我移出div时都不会褪色。
here is the code that I am using: http://jsfiddle.net/jTCdg/11/ 这是我正在使用的代码: http : //jsfiddle.net/jTCdg/11/
The line commented out in the javascript is what changes between all the lists staying visible or the list fadeIn/fadeOut on hover. 在javascript中注释掉的行是所有列表保持可见或悬停时列表fadeIn / fadeOut之间的变化。
This is my first time using javascript so help would be greatly appreciated. 这是我第一次使用javascript,因此非常感谢您的帮助。 thanks
谢谢
jQuery hover is a shortcut for the mouseenter and mouseleave event handlers. jQuery 悬停是mouseenter和mouseleave事件处理程序的快捷方式。 You can define both separately.
您可以分别定义两者。
$(document).ready(function() {
$("#header ul").mouseenter(function() {
$(this).find("li").fadeIn();
});
$("#header").mouseleave (function() {
$(this).find("li").fadeOut();
});
});
Also see the updated jsfiddle . 另请参阅更新的jsfiddle 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.