Javascript 列表关闭和显示
我试图实现的是,每当用户查看一个子类别,然后选择查看另一个子类别时,我都会滑出当前可见的子类别,然后滑下用户希望看到的新子类别 HTML JavaScript/jQueryJavascript 列表关闭和显示,javascript,jquery,Javascript,Jquery,我试图实现的是,每当用户查看一个子类别,然后选择查看另一个子类别时,我都会滑出当前可见的子类别,然后滑下用户希望看到的新子类别 HTML JavaScript/jQuery 将此添加到您的单击功能中:$('.depth one>li>ul')。slideUp(800) 全部代码: $(document).ready(function () { $(".depth-one > li").click(function (e) { $('.depth-one >
将此添加到您的单击功能中:
$('.depth one>li>ul')。slideUp(800)代码>
全部代码:
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$('.depth-one > li > ul').slideUp(800);
if (e.currentTarget == e.target) {
selector = $(this).find(' > .depth-two');
if ($(selector).css("display") == "none") {
$('.depth-one > ul').slideUp(400);
$(selector).slideDown(800);
} else {
selector.slideUp(800);
}
}
});
});
将此添加到您的单击功能:$('.depth one>li>ul').slideUp(800)代码>
全部代码:
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$('.depth-one > li > ul').slideUp(800);
if (e.currentTarget == e.target) {
selector = $(this).find(' > .depth-two');
if ($(selector).css("display") == "none") {
$('.depth-one > ul').slideUp(400);
$(selector).slideDown(800);
} else {
selector.slideUp(800);
}
}
});
});
通过在我对上一个问题的回答中添加一行($('.depth two')。而不是(this).slideUp(800);
),您可以得到所需的结果:
$(document).ready(function () {
$(".depth-one > li").click(function () {
$('.depth-two').not(this).slideUp(800);
selector = $(this).find(' > .depth-two');
if ($(selector).css("display") == "none") {
selector.slideDown(800);
} else {
selector.slideUp(800);
}
});
$('li li').click(function (e) {
e.stopPropagation();
});
});
通过在我对上一个问题的回答中添加一行($('.depth two')。不是(这个)。幻灯片(800);
)可以得到您想要的结果:
$(document).ready(function () {
$(".depth-one > li").click(function () {
$('.depth-two').not(this).slideUp(800);
selector = $(this).find(' > .depth-two');
if ($(selector).css("display") == "none") {
selector.slideDown(800);
} else {
selector.slideUp(800);
}
});
$('li li').click(function (e) {
e.stopPropagation();
});
});
这可能就是您需要的所有代码:
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$(".depth-one > li > .depth-two").slideUp(800);
$(this).find(' > .depth-two').slideDown(800);
});
});
这可能就是您需要的全部代码:
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$(".depth-one > li > .depth-two").slideUp(800);
$(this).find(' > .depth-two').slideDown(800);
});
});
试试这个
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$("ul.toggled").slideToggle().removeClass('toggled');
$('ul', this).slideToggle().addClass('toggled');
});
});
试试这个
$(document).ready(function () {
$(".depth-one > li").click(function (e) {
$("ul.toggled").slideToggle().removeClass('toggled');
$('ul', this).slideToggle().addClass('toggled');
});
});
您可以尝试使用http://jqueryui.com/accordion/
plugin您可以尝试使用http://jqueryui.com/accordion/
plugin如果单击子li,相同的菜单将向上滑动,然后向下滑动。如果单击子li,相同的菜单将向上滑动,然后向下滑动。如果单击子li,相同的菜单将上下滑动如果单击子li,相同的菜单将上下滑动