Jquery 单击并打开一个框,同时关闭另一个框

Jquery 单击并打开一个框,同时关闭另一个框,jquery,Jquery,我有一组框,我不知道子div设置为“无”时的确切数字: <div class="box"> <div class="content"> <div class="info" style="display: none;"></div> <div> <div> <div class="box"> <div class="content">

我有一组框,我不知道子div设置为“无”时的确切数字:

  <div class="box">
     <div class="content">
         <div class="info" style="display: none;"></div>
     <div>
  <div>
  <div class="box">
     <div class="content">
         <div class="info" style="display: none;"></div>
     <div>
  <div>
  <div class="box">
     <div class="content">
         <div class="info" style="display: none;"></div>
     <div>
  <div>

有人吗?

如果您有菜单系统,您可以执行以下操作:

$('.menu a').on('click', function() {
  $('.box').eq($(this).index()).show().siblings().hide();
});

动画制作简单,因此您可以实现它。

不要忘记关闭您的。。。你现在已经开张6次了

你在找这样的东西吗

要查找打开的框,可以执行以下操作:


以下是我在第一个问题中使用html编写的最终解决方案:

$(".box").each(function() {
//we set needed variables
var item = $(this);
var thumb = $("a", item);
var infoBox = $(".info", item);
thumb.click(function (e) {
    e.preventDefault();
    item.addClass("loading");
    $(".box a").fadeIn();
    thumb.fadeOut();
            $(".selected").width(230);
    $(".selected").height(129);
    item.addClass("selected");
    var url = this.href + " .content";
 item.addClass("loading");
 infoBox.css({
    "visibility": "hidden",
"height": "auto"
 });

infoBox.load(url, function () {
var newHeight = infoBox.outerHeight(true);

item.css({
    width: 692,
    height: newHeight
});
infoBox.animate({
    width: 692,
    height: newHeight
}, function () {
    $('#container').isotope('reLayout', function(){
    item.removeClass("loading");
    infoBox.css({"visibility": "visible"});
    var videoSpan = infoBox.find("span.video");
    var iframe = $('<iframe/>', {
            'frameborder' : 0,
            'width' : '692',
            'height' : '389',
            'src' : 'http://player.vimeo.com/video/'+ videoSpan.data("vimeoid") +'?autoplay=0&api=1'
    });
    videoSpan.replaceWith(iframe);
});
});
 });
});
 });

我需要能够实际点击一个框,它不是ul列表,基本上是我发布的纯html标记,我需要能够点击每个框并在关闭之前扩展的框时展开。但是如果你隐藏了框,你怎么能点击它呢?我没有说隐藏,我说的是关闭:显示:无;隐藏盒子。必须有一些其他的方式使框出现,不是吗?如果我提供。显示它将需要显示:无可见,这不是困难,我只是寻找一个通用的循环,能够点击一个框,定义它为选中,因此打开它,而使其他未选中并关闭它们。打开它,我的意思是将它设置为固定的高度和宽度,关闭,我的意思是收回原始的高度和宽度值。如果你打开一个,你需要关闭另一个。是的,我已经尝试将它应用到我需要的东西上。检查更新的问题代码
$(".box:visible").doWhatYouWant();
$(".box").each(function() {
//we set needed variables
var item = $(this);
var thumb = $("a", item);
var infoBox = $(".info", item);
thumb.click(function (e) {
    e.preventDefault();
    item.addClass("loading");
    $(".box a").fadeIn();
    thumb.fadeOut();
            $(".selected").width(230);
    $(".selected").height(129);
    item.addClass("selected");
    var url = this.href + " .content";
 item.addClass("loading");
 infoBox.css({
    "visibility": "hidden",
"height": "auto"
 });

infoBox.load(url, function () {
var newHeight = infoBox.outerHeight(true);

item.css({
    width: 692,
    height: newHeight
});
infoBox.animate({
    width: 692,
    height: newHeight
}, function () {
    $('#container').isotope('reLayout', function(){
    item.removeClass("loading");
    infoBox.css({"visibility": "visible"});
    var videoSpan = infoBox.find("span.video");
    var iframe = $('<iframe/>', {
            'frameborder' : 0,
            'width' : '692',
            'height' : '389',
            'src' : 'http://player.vimeo.com/video/'+ videoSpan.data("vimeoid") +'?autoplay=0&api=1'
    });
    videoSpan.replaceWith(iframe);
});
});
 });
});
 });