jQuery需要修复代码

jQuery需要修复代码,jquery,Jquery,我需要帮助。。。我想添加这种代码效果,比如向上/向下滑动。 我已经添加了这个效果,但唯一的问题是我发现如果我想关闭这个盒子 箱子开着 对不起我的英语 谢谢你的帮助 $(function() { $(".avatar1, .social").hide(); $(".teamBox").click(function() { $(this).find(".avatar1, .social").slideDown('slow') .end().pa

我需要帮助。。。我想添加这种代码效果,比如向上/向下滑动。 我已经添加了这个效果,但唯一的问题是我发现如果我想关闭这个盒子 箱子开着

对不起我的英语

谢谢你的帮助

$(function() {
    $(".avatar1, .social").hide();
    $(".teamBox").click(function() {
        $(this).find(".avatar1, .social").slideDown('slow')
            .end().parent().siblings().find(".avatar1, .social").slideUp('slow');
    });
});

演示

您可以切换功能来执行此操作:

$('.teamBox').click(function() {
     $(this).find('.avatar1, .social').slideToggle('slow');
});

请参阅演示。

您可以通过切换函数来执行此操作:

$('.teamBox').click(function() {
     $(this).find('.avatar1, .social').slideToggle('slow');
});

请参阅演示。

我想您正在寻找类似的内容:

$('.teamBox').click(function () {
    $('.avatar1, .social').slideUp('slow');
    $(this).find('.avatar1, .social').slideDown('slow');
});

我想你正在寻找这样的东西:

$('.teamBox').click(function () {
    $('.avatar1, .social').slideUp('slow');
    $(this).find('.avatar1, .social').slideDown('slow');
});

你可以这样做

$(function() {
    $(".avatar1, .social").hide();
    $(".teamBox").click(function() {
        var $el = $(this).find(".avatar1, .social"); // cache elements to be toggled
        $el.slideToggle('slow'); // only slide toggle current clicked
        $(".avatar1, .social").not($el).slideUp('slow'); // slide up all others
    });
});

你可以这样做

$(function() {
    $(".avatar1, .social").hide();
    $(".teamBox").click(function() {
        var $el = $(this).find(".avatar1, .social"); // cache elements to be toggled
        $el.slideToggle('slow'); // only slide toggle current clicked
        $(".avatar1, .social").not($el).slideUp('slow'); // slide up all others
    });
});

你的HTML看起来像什么?你的HTML看起来像什么?我冒昧地添加了一个演示。我冒昧地添加了一个演示。