var ele = $("#container").children().first();
ele.slideUp(1000, function(ele){
ele.remove();
$("#container").append(ele);
});
该元素不会在回调中被删除或附加到容器中。我认为这可能是语法错误,或者可能是我以错误的方式传递了“ele”变量。不幸的是,“ele”变量的范围似乎无法从回调中访问,因此我猜测它需要作为参数传入。
我确信你们中的一位专家知道解决方案,因此认为这是询问此问题的好地方。
最佳答案
您不需要显式删除
该元素,因为默认情况下.append()
会将元素从一个位置移动到另一个位置。
尝试,
var ele = $("#container").children().first();
ele.slideUp(1000, function(){ //remove the parameter ele here
$("#container").append(ele.show());
});
DEMO
关于jquery - 带有传入变量的 SlideUp 回调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26136410/