我有以下内容(显然我做不到!)
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);
});
}
我想要的是打开一个被点击的,并关闭所有打开的。这个盒子打开了盒子,其他的盒子都没有关上。任何帮助都非常感谢。问候
发布于 2009-09-28 12:55:20
如果以将display
属性更改为none
的方式关闭它们,则可以使用jQuery :visible
选择器选择所有其他打开的对象。
发布于 2009-09-28 13:43:13
有没有人知道为什么这个方法不起作用?
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);
}
});
});
}
上图中,除了被点击的那一个之外,所有人都会被提醒,所以我被难住了。
该死的..。我只是怀疑一下
发布于 2009-09-28 13:55:26
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);
}
});
});
}
成功了!
https://stackoverflow.com/questions/1486852
复制相似问题