我有这个:
$("#id").click(function() {
$('.swoosh div').fadeOut('fast', function(){
$('.template').fadeIn('fast');
});
});
.swoosh
是容器div,和
.template
是我想点击#id
时要保留的div,而.swoosh
内的所有其他div都会消失。
我觉得有点傻,但我已经玩了好几年也无济于事。请帮助一个兄弟。
答案 0 :(得分:4)
您可以使用not
[doc]选择器
$("#id").click(function() {
$('.swoosh div:not(.template)').fadeOut('fast');
});
答案 1 :(得分:2)
$('.swoosh div[class!="template"]').fadeOut('fast');
答案 2 :(得分:0)
$("#id").click(function() {
$('.swoosh div').fadeOut('fast');
$('.template').fadeIn('fast');
});
答案 3 :(得分:0)
由于您正在淡出容器DIV,因此DIV中的所有元素也逐渐淡出似乎是合乎逻辑的。因此,您可以做的是从容器div中提取元素并将其放在DOM中的其他位置,然后将容器DIV淡出。这样,它应该保持可见。
答案 4 :(得分:0)
旧问题,但这也可行
$("#id").click(function() {
$('.swoosh div').not($('.template')).fadeOut('fast');
});