2012-04-03 39 views
0

当我点击一个面板链接“你好”或“嗨”时,那么该面板必须最大化,只有该面板必须显示在页面中,当我再次单击它时需要去它的原始位置,其他面板相同,我尝试实施,但一些我去了,当我点击hello链接它可以最大化,但另一个面板也可以在页面中查看。使用jquery最大化一个框

http://jsfiddle.net/Soni/tRen6/1/ 



<script> 
$(function() { 
    $("#container").sortable({ 
     handle: 'h1', 
     scroll: false, 
     revert: true, 
     tolerance: 'touch' 
    }); 
$(".button").toggle(function() { 
     $(this).parent().animate({ 
      backgroundColor: "#0000", 
      width: 1000, 
     }, 500); 
    }, function() { 
     $(this).parent().animate({ 
      backgroundColor: "#000", 
      width: 100, 

     }, 500); 
    }); 

}); 

回答

0

不是一个优雅的方式,但它工作

$(function() { 
$("#container").sortable({ 
    handle: 'h1', 
    scroll: false, 
    revert: true, 
    tolerance: 'touch' 
}); 

$(".button").toggle(function() { 
    $(this).parent().animate({ 
     backgroundColor: "#0000", 
     width: 500, 
    }, 500); 
    $(".button").fadeOut(); 
    $(this).fadeIn(); 
}, function() { 
    $(this).parent().animate({ 
     backgroundColor: "#000", 
     width: 100, 
    }, 500); 
    $(".button").fadeIn(); 
    $(this).fadeIn(); 

}); 

}); 

看看它`解决。

您还可以看到nextbefore

或者可能创建一个类来每个元素系列。

或尝试用eq()计数。但我不知道你要去哪里使用。

+0

不,这不是我想象的,当我点击一个面板,然后它需要最大化并使其他面板隐藏,当我点击相同的面板按钮,然后它需要回到原始位置 – Navyah 2012-04-03 13:02:06

+0

让我们来看看。 1)打开了painels。 2)点击'你好','嗨'消失了(就像你可以点击它了)。 3)如果再次点击'你好'>你好,但'嗨'回来或不? 也许(只是也许)你正在寻找像[这](http://jqueryui.com/demos/accordion/)的某些东西? – JGSilva 2012-04-03 17:15:39

+0

不,不是,有些东西像左上角的窗口浏览器按钮,我有2个框ia页,左上角会有一个maxmiize按钮,如果我想最大化一个框然后它需要在页面上最大化,(像浏览器窗口按钮) – Navyah 2012-04-04 06:57:44