你好,我有一个jquery下拉列表:
$('div a').hover(function() {
$('.submenu').not(this).children('li').slideUp("slow");
$(this).children('li').slideToggle("slow");
});
现在它已经倒塌了,当我悬停在一个菜单项上时,它就会向上滑动。我如何使状态的位置是向上的,以及当我悬停下来的时候。
此外,如何只能在子菜单下面的悬停菜单项崩溃。现在,当我悬停在一个,所有的子菜单崩溃。我知道使用"div a“,因为这可能不是很聪明,但我真的不能给每个切换菜单项目一个不同的id。那么,有没有一种方法可以告诉jquery只崩溃徘徊的"div“的子代?
我是个十足的菜鸟!
http://jsfiddle.net/CBKZK/
发布于 2014-04-05 10:17:43
像这样使用
$('.dropdown-menu').click(function() {
$('.dropdown-menu').not(this).children('ul').slideUp("slow");
$(this).children('ul').slideToggle("slow");
$(".thisismobile").find("a").next().show();
});
$(".thisismobile").find("a").hover(
function() {
$( this ).next().slideDown();
}, function() {
$( this ).next().slideUp(); }
);
Demo
编辑
$('.dropdown-menu').click(function() {
$('.dropdown-menu').not(this).children('ul').slideUp("slow");
$(this).children('ul').slideToggle("slow");
$(".thisismobile").find("a").next().show();
});
$(".thisismobile").find("a").hover(function(){
$( this ).next().slideDown();
});
$(".submenu").mouseleave(function(){
$( this ).slideUp();
});
Updated Fiddle
发布于 2014-04-04 12:55:29
第一:
$(document).ready(function(){
$(this).children('li').slideToggle("slow"); // seting initial state
$('div a').hover(function() {
$('.submenu').not(this).children('li').slideUp("slow");
$(this).children('li').slideToggle("slow");
});
});
我不太清楚你的第二点,也许你可以提供一些html。
https://stackoverflow.com/questions/22863367
复制相似问题