2009-09-28 134 views
0

我有以下(这很明显,我不能这样做!)打开一个盒子,关闭所有打开的

function dropBox() { 
    $("#reportWrapper a").bind("click", function(){ 
     $("#reportWrapper a").each(function(i){ 
      $(this).animate({ 
         height: '20px' 
      }, 1000);        
     }); 
     $(this).parents("div:eq(0)").animate({ 
      height: '100px' 
     }, 1000); 
    }); 
} 

我要的是打开一个被点击并关闭所有打开的。盒子打开盒子,其他人不关闭。任何帮助非常感谢。 问候

+0

你可以把一部分HTML代码来帮助你吗? – 2009-09-28 13:29:36

回答

0

如果在该display属性更改为none的方式关闭它们,那么你可以使用jQuery的:visible选择器选择打开的所有其他人。

+0

对不起,即时通讯新的jQuery(PHP的人)你可以精心策划一些? – 2009-09-28 13:01:35

+0

can yoiu是通过CSS属性选择一个元素?即element.css.height.200px? – 2009-09-28 13:02:52

0

可以enyone看到为什么这不工作?

function dropBox() { 
    $("#reportWrapper a").bind("click", function(){ 
     var clicked = $(this); 
     $("#reportWrapper a").each(function(){ 
      if(clicked.attr("name") != $(this).attr("name")) 
      { 
       $(this).animate({ 
        height: '20px' 
       }, 1000); 
      } 
      else 
      { 
       clicked.parents("div:eq(0)").animate({ 
        height: '100px' 
       }, 1000); 
      } 
     }); 
    }); 
} 

再次,框点击打开,但一个是开不关闭

function dropBox() { 
    $("#reportWrapper a").bind("click", function(){ 
     var clicked = $(this); 
     $("#reportWrapper a").each(function(){ 
      if(clicked.attr("name") !== $(this).attr("name")) 
      { 
       alert("this: " + $(this).attr("name") + "clicked: " + clicked.attr("name")); 
       $(this).animate({ 
        height: '20px' 
       }, 1000); 
      } 
      else 
      { 
       clicked.parents("div:eq(0)").animate({ 
        height: '100px' 
       }, 1000); 
      } 
     }); 
    }); 
} 

以上,提醒大家除了那个那点击这样的IM难倒

该死...只是sussed它

0
function dropBox() { 
    $("#reportWrapper a").bind("click", function(){ 
      var clicked = $(this); 
      $("#reportWrapper a").each(function(){ 
        if(clicked.attr("name") !== $(this).attr("name")) 
        { 
          $(this).parents("div:eq(0)").animate({ 
            height: '20px' 
          }, 1000); 
        } 
        else 
        { 
          clicked.parents("div:eq(0)").animate({ 
            height: '100px' 
          }, 1000); 
        } 
      }); 
    }); 

}

作品!

相关问题