Jquery 使用next()向右滑动;

Jquery 使用next()向右滑动;,jquery,html,css,Jquery,Html,Css,我想做的是下一次我点击。div最后一个动画,并使其他功能,我仍然不知道如何做到这一点 $(".div").click(function() { /*with this code i make that the next time i open .show, the last one closes */ $(this).next('.show').slideToggle(); $(this).parent().siblings().children().next().sli

我想做的是下一次我点击。div最后一个动画,并使其他功能,我仍然不知道如何做到这一点

$(".div").click(function() {
    /*with this code i make that the next time i open .show, the last one closes */
    $(this).next('.show').slideToggle();
    $(this).parent().siblings().children().next().slideUp();
    /*here i use a flag to slide a div and make some animations*/
    if (!$(this).hasClass("flag")) {
        $(this).animate({
            marginLeft: '-=400px'
        }, 100);
        $(this).addClass("flag");
        $(this).find("h1").animate({
            backgroundColor: 'black'
        }, 500);
        $(this).find("h1").css("color", "white");
        $(this).find("h1").addClass("class1");
    } else {
        $(this).animate({
            marginLeft: '+=400px'
        }, 100);
        $(this).removeClass("flag");
        $(this).find("h1").animate({
            backgroundColor: 'transparent'
        }, 500);
        $(this).find("h1").css("color", "black");
        $(this).find("h1").removeClass("class1");
    };
    return false;
});

我建议在切换单击的项目时隐藏所有其他项目

在下面的演示中,我创建了两个函数:一个用于“切换”项目,另一个用于“隐藏”项目。
通过操纵“打开”类并滑动相关内容来显示/隐藏项目。
单击某个项目时,所有未单击的项目都将隐藏,并切换单击的项目

我使用了一个按钮来设置标题的动画,但是如果您愿意,可以使用jQuery。
使用CSS转换实现“slideDown”效果比较困难,所以我使用jQuery来实现

我还将
.first().click()
链接到我的click处理程序选择器的末尾,以便第一个项目将自动打开

var$containers=jQuery('.container');
功能切换项($item){
$item.toggleClass('open');
$item.find('.content').slideToggle(200);
}
函数hideItem($item){
$item.removeClass('open');
$item.find('.content').slideUp(200);
}
jQuery('h1',$containers.)。在('click',function()上{
var$container=jQuery(this.parent();
hideItem($containers.not($container));
toggleItem($container);
}).first().click()
.container{
字体大小:14px;
}
.容器.内容{
显示:无;
利润率:1米0;
}
.集装箱h1{
字号:1.5em;
保证金:0;
左侧填充:0;
颜色:黑色;
-webkit转换:填充左.2s,颜色.2s,背景色.2s;
过渡:填充左.2s,颜色.2s,背景色.2s;
}
.container.openh1{
左侧填充:40px;
颜色:白色;
背景色:黑色;
}

标题
内容
内容
内容 标题 内容
内容
内容 标题 内容
内容
内容
您也可以发布html吗?在这里,我试图制作动画的部分是这个#PRODUCCIÓNPOÉTICA这是重要的部分,我想,很抱歉我的代码很混乱,但我需要考虑如何在下次单击另一个时制作它。div是最后一个。div生成其他函数的功能